-
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
SQL: wrong query when LIKE and NOT LIKE are used together with aggregate functions #39931
Comments
Pinging @elastic/es-search |
@broodfusion First off, thank you for the detailed issue report! FWIW, I've tried your query against master and the query is generated correctly: "query" : {
"bool" : {
"must" : [
{
"query_string" : {
"query" : "B 4E*",
"fields" : [
"first_name^1.0"
],
"type" : "best_fields",
"default_operator" : "or",
"max_determinized_states" : 10000,
"enable_position_increments" : true,
"fuzziness" : "AUTO",
"fuzzy_prefix_length" : 0,
"fuzzy_max_expansions" : 50,
"phrase_slop" : 0,
"escape" : false,
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must_not" : [
{
"query_string" : {
"query" : "B 4E D*",
"fields" : [
"last_name^1.0"
],
"type" : "best_fields",
"default_operator" : "or",
"max_determinized_states" : 10000,
"enable_position_increments" : true,
"fuzziness" : "AUTO",
"fuzzy_prefix_length" : 0,
"fuzzy_max_expansions" : 50,
"phrase_slop" : 0,
"escape" : false,
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
} Thank you. |
Hi @costin thanks for the response. However it looks like you're not using it with aggregate functions in the above query. This works fine without aggregate functions, but when used in combination with aggregate functions such as Try doing something like this:
Output from Kibana
Thanks for looking into this! |
Actually, the presence of |
Elasticsearch version (
bin/elasticsearch --version
):6.6.1
Plugins installed: []
JVM version (
java -version
):OS version (
uname -a
if on a Unix-like system):macOS Mojave 10.14.3
Description of the problem including expected versus actual behavior:
Not sure if this is a current limitation as I could not find any documentation explicitly stating this issue as described below:
When performing an SQL query using aggregate functions such as COUNT(), AVG() with
LIKE
andNOT LIKE
, the actual performed query is not as expected.Using the
translate
API, we can see the issue more clearly in Kibana:In the below response, we see that the wildcard in
must
and wildcard inmust_not
are exactly the same. Therefore the expected query data will not be returned correctly.Response:
Expected:
Steps to reproduce:
Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.
call
and a fieldstation
that has mapping:station
(optional)translate
API, check the result of using the belowProvide logs (if relevant):
The text was updated successfully, but these errors were encountered: