Elasticsearch: Highlight breaks when setting fuzziness to 0

Created on 9 Aug 2019  路  6Comments  路  Source: elastic/elasticsearch

Elasticsearch version
7.3.0

Description:
When we run a search query with highlight and fuzziness explicitly set to 0, the search result is returned but without the highlight. It was working fine with elastic 7.2.0, it is also working if we set the fuzziness to different value or we delete it.

Steps to reproduce:

  1. Create simple index, add some data:
PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "properties" : {
            "field1" : { "type" : "text" }
        }
    }
}

PUT test/_doc/1
{
    "field1" : "value1"
}

PUT test/_doc/2
{
    "field1" : "other"
}
  1. Send a search request with highlight and fuzziness set to 0:
POST test/_search
{
  "highlight": {
    "fields": {
      "field1": {}
    }
  },
  "query": {
        "fuzzy" : {
            "field1" : {
                "value": "value1",
                "fuzziness": 0
            }
        }
  }
}

Expected:
Hits returned with highlight
Actual:
Hits returned without highlight

:SearcHighlighting Search

Most helpful comment

Hey,
Is there any update on this?
I just ran into the same Bug as we have a default with Fuzziness AUTO, but allow to turn it down to 0, which breaks the highlighting.

All 6 comments

Pinging @elastic/es-search

@michal-lyson Thank you for filing the issue. I confirm the bug.

The bug occurs only when fuzziness is 0; with fuzziness of 1,2, and AUTO highlighting works well.

The reason highlight doesn't happens as UnifiedHighlighter::getOptimizedOffsetSource returns OffsetSource.NONE_NEEDED for fuzziness =0, while returns offsetSource.ANALYSIS for other fuzziness.
This happens because UnifiedHighlighter:getAutomata changed in such a way that from ES 7.3 it returns ZERO_LEN_AUTOMATA_ARRAY.

Hey,
Is there any update on this?
I just ran into the same Bug as we have a default with Fuzziness AUTO, but allow to turn it down to 0, which breaks the highlighting.

When I set "highlight" : {
"fields" : {
"filed1" : {"type":"plain"}
}
}
it works

I opened a Lucene PR with a proposed fix: https://github.com/apache/lucene-solr/pull/1671.

The Lucene PR was merged, so this should be fixed in the upcoming ES version 7.10. Please reopen the issue if you test the new version and still notice issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpountz picture jpountz  路  75Comments

rjernst picture rjernst  路  43Comments

geekpete picture geekpete  路  59Comments

monken picture monken  路  160Comments

kul picture kul  路  72Comments