Which index(element) of an array are the ones that matched in highlight search results ?
I'm using the elasticsearch.js of the elasticsearch 5.1.1 .
The data item is as follows:
{
"data" :
[{
"grade" : 1,
"comment" : " This is test program"
},
{
"grade" : 2,
"comment" : " This is test program"
},
{
"grade" : 3,
"comment" : " This is commercial program"
}]
}
The query is as follows :
"query": {
"bool": {
"must": [
{
"nested": {
"query": {
"query_string": {
"fields": ["data.comment"],
"query": "commercial"
}
},
"path": "data"
}
} ]
} } ,
"highlight": {
"fields" : {
"data.comment":{
"number_of_fragments" : 0,
},
},
"pre_tags": [''],
"post_tags": [""]
}
I received the result as follows :
"_source": {
omitted..
},
"highlight": {
"data.comment": [
" This is <span style="font-weight:bold;color:blue">commercial program"
]
}
}
The result is the third index(element) of "data" . But I can't know the which index(element) of array in this results.
I can only know the value of array.
How can I know the array position (index) ?