In the docs, if I do
GET twitter/_search
{
"query" : {
"match_phrase": { "message": "number 1" }
},
"highlight" : {
"fields" : {
"message" : {
"type": "plain",
"fragment_size" : 15,
"number_of_fragments" : 3,
"fragmenter": "simple"
}
}
}
}
A normal response is something like this (slightly modified message to be an array)
{
...
"hits": {
"total": 1,
"max_score": 1.601195,
"hits": [
{
"_index": "twitter",
"_type": "_doc",
"_id": "1",
"_score": 1.601195,
"_source": {
"user": "test",
"message": ["some message with the number 1"],
"date": "2009-11-15T14:12:12",
"likes": 1
},
"highlight": {
"message": [
" with the <em>number</em>",
" <em>1</em>"
]
}
}
]
}
}
How do I get highlight with structured data? EG:
{
...
"hits": {
"total": 1,
"max_score": 1.601195,
"hits": [
{
"_index": "twitter",
"_type": "_doc",
"_id": "1",
"_score": 1.601195,
"_source": {
"user": "test",
"message": ["some message with the number 1"],
"date": "2009-11-15T14:12:12",
"likes": 1
},
"highlight": {
"message": [{
"type": 'plain',
"content": "some message with the ",
"for" : "0"
}, {
"type": 'highlight',
"content": "number",
"for" : "0",
"style": "hlt1",
// "query" might be highlighted with similar data structure
}, {
"type": 'highlight',
"content": "1",
"for" : "0",
"style": "hlt2"
} ]
}
}
]
}
}
for
is to reference which element in the message
array. The point of it is to reference the part in the source.