-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Search Relevance/HighlightingHow a query matched a documentHow a query matched a document>bugTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch
Description
Following this issue: #25088
Elasticsearch version: 5.4.0 and 5.4.1
JVM version: 1.8
OS version : Windows 7
No highlights returned using a prefix in a highlight_query when a document attribute has an empty value or no match found
Steps to reproduce:
Create the following index
PUT foo
{
"mappings": {
"blogpost": {
"properties": {
"title": { "type": "text", "term_vector": "with_positions_offsets"},
"description": { "type": "text", "term_vector": "with_positions_offsets" }
}
}
}
}
Add a new document, notice description is empty (no match for 'sq' string).
PUT foo/entry/1
{
"title": "SQ05_H04_WorldTour test",
"description": ""
}
Run the following query to highlight the string containing 'sq'.
GET foo/_search
{
"query":{
"match_all":{ }
},
"highlight":{
"fields":{
"title":{
"number_of_fragments":10,
"type":"fvh",
"highlight_query":{
"prefix":{
"title":"sq"
}
}
},
"description":{
"number_of_fragments":10,
"type":"fvh",
"highlight_query":{
"prefix":{
"description":"sq"
}
}
}
},
"require_field_match":false
}
}
The result as expected highlights the string containing 'sq'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "foo",
"_type": "entry",
"_id": "1",
"_score": 1,
"_source": {
"title": "SQ05_H04_WorldTour test",
"description": ""
},
"highlight": {
"title": [
"<em>SQ05_H04_WorldTour</em> test"
]
}
}
]
}
}
Lets re-execute the same query, but this time we change the order of fields..
GET foo/_search
{
"query":{
"match_all":{ }
},
"highlight":{
"fields":{
"description":{
"number_of_fragments":10,
"type":"fvh",
"highlight_query":{
"prefix":{
"description":"sq"
}
}
},
"title":{
"number_of_fragments":10,
"type":"fvh",
"highlight_query":{
"prefix":{
"title":"sq"
}
}
}
},
"require_field_match":false
}
}
Surprisingly, no highlighs returned..
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "foo",
"_type": "entry",
"_id": "1",
"_score": 1,
"_source": {
"title": "SQ05_H04_WorldTour test",
"description": ""
}
}
]
}
}
is this is a bug? same behavior in 2.x
Metadata
Metadata
Assignees
Labels
:Search Relevance/HighlightingHow a query matched a documentHow a query matched a document>bugTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch