Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight for Pinned Query not Working #53699

Closed
jesserobles opened this issue Mar 17, 2020 · 4 comments · Fixed by #53716
Closed

Highlight for Pinned Query not Working #53699

jesserobles opened this issue Mar 17, 2020 · 4 comments · Fixed by #53716
Assignees
Labels
:Search Relevance/Highlighting How a query matched a document Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@jesserobles
Copy link

Elasticsearch version (bin/elasticsearch --version): 7.4.2, 7.6.1

Plugins installed: repository-s3

JVM version (java -version):
openjdk 13.0.2 2020-01-14 OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.2+8) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.2+8, mixed mode, sharing)

OS version (uname -a if on a Unix-like system):
Docker (from docker.elastic.co): Linux ce1452e52a27 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
Highlighting does not work when wrapping queries using the Pinned query, even though the issue at #44074 describes pinned results as being highlight-able. At the very least, the organic results should be highlighted.
Steps to reproduce:

Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.

POST _bulk
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "title" : "elasticsearch is great" }
{ "index" : { "_index" : "test", "_id" : "2" } }
{ "title" : "kibana is pretty cool too" }
{ "index" : { "_index" : "test", "_id" : "3" } }
{ "title" : "another elasticsearch document" }

# Highlighting doesn't work with this:
GET test/_search
{
 "highlight": {
   "fields": {
     "title": {}
   }
 }, 
 "query": {
   "pinned": {
     "ids": ["3"],
     "organic": {
       "match": {
         "title": "elasticsearch"
       }
     }
   }
 }
}

# Highlighting works with the organic query:
GET test/_search
{
 "highlight": {
   "fields": {
     "title": {}
   }
 }, 
 "query": {
   "match": {
     "title": "elasticsearch"
   }
 }
}
@danielmitterdorfer danielmitterdorfer added the :Search Relevance/Highlighting How a query matched a document label Mar 18, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Highlighting)

@markharwood markharwood self-assigned this Mar 18, 2020
@markharwood
Copy link
Contributor

I'll look into this. A workaround is to reiterate the organic part of the query in the highlight section like so:

GET test/_search
{
  "highlight": {
	"fields": {
	  "title": {}
	},
	"highlight_query": {
	  "match": {"title": "elasticsearch"}
	}
  },
  "query": {
	"pinned": {
	  "ids": [
		"3"
	  ],
	  "organic": {
		"match": {"title": "elasticsearch"}
	  }
	}
  }
}

@markharwood
Copy link
Contributor

markharwood commented Mar 18, 2020

Will be fixed in 7.7 onwards. Thanks for reporting @jesserobles

@jesserobles
Copy link
Author

jesserobles commented Mar 18, 2020

Awesome! Thanks for the workaround, and for fixing it so quickly @markharwood .

@javanna javanna added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search Relevance/Highlighting How a query matched a document Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants