Can Elasticsearch or Elastic Cloud return response with matched position?
Example request
{ "query": { "match": { "body": "apple" } } }
Ideal response
{
"_source": {
"body": "The red apple is a good apple."
},
"matched_position": [
{
"start": 8,
"end": 12,
},
{
"start": 24,
"end": 28,
}
]
}
If you need the offset and not only the highlighted text, you will need to implement custom highlighter (plugin).
An example highlighter plugin: https://github.com/wikimedia/search-highlighter - note that you would have to adjust it to 7.X version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With