Azure search highlights doesn't only match fields used in Lucene field-scoped query

268 views Asked by At

In Azure Search, it seems that highlights doesn't only match fields used in Lucene field-scoped query.

Index:

Id | Field_1 | Field_2
-----------------------
1  | Foo     | Foo
2  | Bar     | Foo

Query:

queryType=Full&search=Field_1:(Foo)&highlight=Field_1,Field_2

Result:

{
  "value": [
    {
      "Id": "1",
      "Field_1": "Foo",
      "Field_2": "Foo",
      "@search.highlights": {
        "Field_1": [
          "<em>Foo</em>"
        ],
        "Field_2": [
          "<em>Foo</em>"
        ]
      }
    }
  ]
}

The item in the result is as expected except for the highlight Field_2. As the search is done on Field_1, I would expect only highlights on Field_1.

Am I wrong somewhere ? Thx

1

There are 1 answers

0
Bruce Johnston On BEST ANSWER

Highlighting is controlled separately from the query. This is because highlighting is actually a separate step that happens after the query has found all matching documents. If you don't want Field_2 highlighted, don't mention it in the highlight parameter.