Unexpected behaviour when using synonyms with match and multi-match queries #97396
Labels
>bug
:Search/Search
Search-related issues that do not fall into other categories
Team:Search
Meta label for search team
Elasticsearch Version
8.7.1
Installed Plugins
No response
Java Version
20.0.1
OS Version
ubuntu, but running in the azureaks vm image
Problem Description
Say I have an analyser called 'searchAnalyser' which contains the synonym
bar => bar, baz
. All the queries mentioned below will be using this analyser at search time.Say I have four documents within my index which contain a name and a description:
Current behaviour
Scenario 1
When performing a multi-match query with the default type
best_fields
the results are missing documents that do not contain the search term in the first property that is checked.The query performed:
We will only receive back document_1 and document_2, and not receive back document_3 and document_4.
Scenario 2
When performing a bool query with a minimum_should_match of 1, and two match_phrase 'should' queries the results are missing documents that do not contain the search term in the first match_phrase query.
The query performed:
We will only receive back document_1 and document_2, and not receive back document_3 and document_4.
Expected behaviour
Both the multi-match and match queries should have brought back all 4 documents. It looks like if you are using synonyms and the terms do not appear in the first property that is checked then the document is not returned.
Steps to Reproduce
The bodies for each request to es have been added to the following gist: https://gist.github.com/elliotthumphreys/834bde8eef763d4f8b7b5655e0237346
bar => bar, baz
2.1. document1.json
(name: foo, description: bar)
2.2. document2.json
(name: bar, description: foo)
2.3. document3.json
(name: baz, description: foo)
2.4. document4.json
(name: foo, description: baz)
searchAnalyser
with the synonyms. You will observe that only documents 2 and 3 are returned, however, all 4 documents should have been returned as they all contain either bar or baz.searchAnalyser
. This also only returns 2 documents.Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: