During Elasticsearch or Opensearch query, I can request the returned highlight snippet sorted by score.
"highlight": {
# "order": "score", # order can be inside fields or outside below highlight
"fields": {
# this order-by-score is very important, so we can find the most relevant
"text": {"order": "score"}
}
}
Is there a way that the returned snippets come with its score?
Let's say document A returns snippet 1 and snippet 2; document B returns snippet 3 and snippet 4. I know there is a score associated with doc A and doc B. However, I am more interested in the snippet, and I need a way to help me decide which snippets are best for me to display to users.
The following is what I got from the query. As I explained before, what I would like to have are the scores Elasticsearch used to sort highlight snippets.
{
'_index': 'myindex',
'_type': '_doc',
'_id': 'id0001',
'_score': 2.1239817,
'highlight': {
'text': [
"I've got new English lessons coming out for <em>you</em> every week so make sure <em>you</em> subscribe and <em>I</em> <em>will</em> <em>see</em>",
'Make sure <em>you</em> check it out and <em>I</em> hope to <em>see</em> <em>you</em> inside.',
'get to bump into someone practise these little useful phrases and <em>I</em> promise <em>you</em> with time it <em>will</em> become',
"it's great to <em>see</em> <em>you</em> here! If <em>you</em> haven't heard yet, Hey Lady!",
'that <em>you</em> can <em>see</em> yourself using in a particular situation in your life.'
]
}
}