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:
PUT test
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
PUT test/_doc/1
{
"field1" : "value1"
}
PUT test/_doc/2
{
"field1" : "other"
}
POST test/_search
{
"highlight": {
"fields": {
"field1": {}
}
},
"query": {
"fuzzy" : {
"field1" : {
"value": "value1",
"fuzziness": 0
}
}
}
}
Expected:
Hits returned with highlight
Actual:
Hits returned without highlight
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.
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.