Azure Search result highlight snippets

1.2k views Asked by At

I am using the Hit Highlighting feature in Azure Search and noticed a discrepancy in the way it behaves from the documentation. In the documentation it says that when you use hit highlighting it will return a snippet of the field with the highlight, but it always returns the entire field (with proper highlighting).

Is there a way to have Azure Search instead return just a snippet (say of about 200 characters) that includes the highlight?

3

There are 3 answers

0
karask On BEST ANSWER

Currently, the answer is no, you cannot. The field breaks according to (English) sentence rules, ie. it breaks on ".", "!", "?".

Also see this question for an example on breaking and some more info relating to the delimiters.

Depending on the nature of the field you might be able to add one of the above delimiters to 'emulate' what you want to accomplish (as suggested by Nate Ko).

0
Nate Ko On

We recently introduced a change that improves the highlighter performance on large fields and NLP experience. One side effect of the change was that the new highlighter generates snippets based on sentences, breaking the text field on '.' (period).

One way to workaround the issue is to put '.'s in the field. We are working to enforce the snippet size and let you know when it is available.

1
Liam Cavanagh - MSFT On

I want to suggest something else on top of what Nate spoke to. When you look at the document response, also take a look at the Highlights part of the results (as opposed to the Document). For example, you might be currently getting the field results by retrieving something like this:

Results[i].Document.DESCRIPTION

If there is a highlight found for that field, the snipped will be found here:

Results[i].Highlights.DESCRIPTION

What I like to do is to first check if there is a valid Highlight and if so display it. If not, I show the actual field content.

Liam