-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Omit noMatchDocs in a bool query #110080
Comments
Pinging @elastic/es-search (Team:Search) |
I don't understand this @atsushi-matsui . Omitting a clause is the same as now "matching all docs" given the clause. In your first example, it seems the following would work fine:
Then in your second example, omitting BOTH clauses (which is what would happen in this case), is the exact same as a
That is the exact same as a |
@benwtrent
I understand that the second example is equivalent to match_all, but there are cases where we want to omit the clause, so I'll show you another example. When building a search system using Elasticsearch in Japan, it is common to prepare kuromoji and a 2-gram analyzer.
In Japan, it is common to search by entering phrases separated by spaces, so we can construct bool_query using words separated by spaces as phrases.
If we omit the "☆" in our search, we may find works by "遊☆戯☆王".
Therefore, I would like bool_query to have a function that omits the clause. |
The organization I work for is actually facing this problem. |
@atsushi-matsui I am still not understanding, could you give me a document you would expect to match and one that wouldn't with your most recent example (thus requiring the feature change)? I am just trying to confirm the behavior as it still isn't clear to me how omitting a clause is any different than making that clause a match_all. |
@benwtrent Register the following data.
|
If you set the query as "遊 ☆" in query_string as shown below, it will appear that the search is executed only for "遊".
|
@atsushi-matsui for your docs, what is the mapping configured? including any custom analyzers please. Thank you for your patience :). Excluding vs. including vs. match_none vs. match_all is tricky to reason about. |
This is my setting used to confirm operation.
|
I created a verification environment, so please use it if you like. |
Hi, @benwtrent. |
Description
Problem
When multiple queries are listed in the must field of a bool query, if even one of the queries does not hit the document, there will be zero hits.
As a workaround, you can set zero_terms_query, which is provided in match query, to "all", but this causes another problem in that all queries will be hit even if none of the queries in the must field hit the document.
If "the" is excluded by the token filter, 0 hits will be returned.
Stop words are excluded by the token filter, so we expect zero hits, but all hits are returned
proposal
For this reason, we would like to provide an option called omit_zero_term_query in the bool query to ignore queries that do not hit the document.
The text was updated successfully, but these errors were encountered: