-
Notifications
You must be signed in to change notification settings - Fork 25k
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
minimum_should_match is not working for query_string query while searching on attachment field #34142
Comments
Pinging @elastic/es-search-aggs |
I'll have a look at this one. |
I don't think your recreation is correct. The
So that's not really a bug, just a side effect of the fact that we don't consider whitespaces as operators anymore. Here is the same query if you use an explicit
One way to retrieve the old behavior is to add |
Thanks a lot for the very detailed explanation and examples @jimczi! That's a tricky area 😅 I need play a tiny bit more with the |
Alright, I've played a tiny bit more with this query. You've probably explained it before and I wasn't able to understand, but here it is with my own understanding of the issue: in the updated recreation script, the Is it this side effect you talked about? In the updated recreation query is made of terms Explain output with only one field ( {
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"valid" : true,
"explanations" : [
{
"index" : "index1",
"valid" : true,
"explanation" : "+title:title1 +((attachment.content:foo attachment.content:bar attachment.content:baz attachment.content:azerty attachment.content:qwerty attachment.content:elastic attachment.content:lucene)~4)"
}
]
} Explain output with all three fields in query, one hit because no {
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"valid" : true,
"explanations" : [
{
"index" : "index1",
"valid" : true,
"explanation" : "+title:title1 +((attachment.content:foo attachment.content:bar attachment.content:baz attachment.content:azerty attachment.content:qwerty attachment.content:elastic attachment.content:lucene) | (message:foo message:bar message:baz message:azerty message:qwerty message:elastic message:lucene) | (address:foo address:bar address:baz address:azerty address:qwerty address:elastic address:lucene))"
}
]
} |
No, it doesn't work in your recreation because you don't use explicit operator ( |
I've got it, thanks for the (very) quick and detailed answer @jimczi, I've played with explicit operators and it worked as I expected. I should now have everything I need to suggest a documentation improvement 👍 For future readers of this issue, here is a short summary of these experiments.
|
Hi, here is a documentation improvement proposal in PR #36109. |
I am using following query with explicit OR and AND. But it does not return expected result. Here it is ambiguous that for which field min should match will be applied. What am I missing ? |
@rutuls we are using github for bug reports and feature requests. The best place to ask questions like this would be our discussion forum. To get a timely response, please add the output of the command and explain what result you would have expected and how they are different form what you actually get. |
Elasticsearch version (
bin/elasticsearch --version
): 6.1.2Plugins installed: [ingest-attachemnt, analysis-phonetic]
JVM version (
java -version
): 1.8.181OS version (
uname -a
if on a Unix-like system): Windows 2012R2Description of the problem including expected versus actual behavior:
While using query_string query with multiple fields provided in fields attribute, if one of the field is attachment content field, minimum_should_match is not giving expected behavior. For example, if the search text is "foo bar" and minimum_should_match as 100%, it returns documents with either foo or bar which is not expected. If I specify operator in the search text like "foo OR bar" with minimum_should_match as 100% it looks for both foo and bar in the document.
Steps to reproduce:
Query used:
{ "query":{ "bool":{ "must":[ { "match":{ "title":"English" } }, { "query_string": { "fields":[ "address", "message", "attachment*.content" ], "query":"foo bar", "minimum_should_match":"100%" } } ] } } }
all the properties are mapped with custom analyzer shown below.
"my_custom_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "standard" ] }
This works as expected if I remove the field "attachment*.content" from the list of fields.
The text was updated successfully, but these errors were encountered: