Details
-
Bug
-
Resolution: Not a Bug
-
Minor
-
7.1.0
-
Untriaged
-
1
-
Unknown
Description
Using travel-sample is I index reviews.content and if I do a query either on "highlight": {} or on "fields": ["reviews.content"] things work correctly.
But if I do both "highlight": {} and "fields": ["reviews.content"] only the "highlight" is emitted in the UI and the array of matches form "fields" is suppressed.
The UI only returns one item (the highlight) per each matching doc - but the REST API emits both the (single) highlight and also the array of fields per each matching doc .
The query I used
{
|
"explain": true,
|
"fields": [
|
"reviews.content"
|
],
|
"highlight": {},
|
"query": {
|
"match_phrase": "streetcar"
|
},
|
"size": 10,
|
"from": 0
|
}
|
I think this happens because both the fragment and the fields map into the same key in the UI's JavaScript code when rendering the results for the UI, the behavior may actually be by design, since highlighting only returns and highlights one of the match items (if there is more than one match).
However the UI and the REST API really should provide the same information.
Perhaps the highlight should display as a one item JSON array in the UI note the prepend with "fragments."
fragments.reviews.content: [
|
"â¦..... <mark>streetcar</mark> .....â¦"
|
]
|
and the fields as an N item array
reviews.content: [
|
<match1>,
|
<match1>,
|
.....
|
<matchN>
|
]
|