-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
"query_string" parser has changed in 7.x to allow bad percolator queries #71532
Comments
Pinging @elastic/es-search (Team:Search) |
Hello @ymsoftware, I looked into this and it indeed seems like there was a change to percolator query parsing in 7.7. However I'm not sure the old behavior was preferable. I tried running this query, and it succeeds on 6.8 and the 7.x series:
So the current percolator parsing logic is more consistent with how we usually parse these queries. Is there some way in which causes problems for your application, or were you just surprised to see a difference between versions? If it's the latter, maybe we can just close this out. |
Hi, |
Agreed, I think we changed how unmapped fields are checked when expanding the target field list in our query parsers. That removed the validation which in the context of the percolator throw an error in presence of an unknown field. We should fix that change to call |
Thanks @ymsoftware and @jimczi for the additional details. I see the problem now, before I didn't understand that percolator parsing is stricter than usual query parsing in terms of how it handles unmapped fields. From testing, this change actually happened in 7.7 so I'm not sure #63322 is the reason. As a guess #52486 might be relevant, which started to rewrite percolator queries prior to storing them, and had a small refactor. I agree we should look into why this changed. |
Have you found the reason why the behavior changed? Will this new behavior an official feature or is subject to change? For our case, I don't know whether we can rely on this behavior to allow the unmapped field in the percolator query. Previously we had code to validate the percolator query. |
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
Elasticsearch version (
bin/elasticsearch --version
): 7.9.1Plugins installed: []
JVM version (
java -version
):OS version (
uname -a
if on a Unix-like system): Amazon hosted, WindowsDescription of the problem including expected versus actual behavior:
"query_string" parser has changed in 7.x to allow some bad percolator queries; its validation is less strict than it used to be in previous versions (6.x)
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.
curl -X PUT "localhost:9200/test" -H 'Content-Type: application/json' -d' { "settings": { "index": { "number_of_shards": "1", "number_of_replicas": "0" } }, "mappings": { "dynamic": "false", "properties": { "query": { "type": "percolator" }, "message": { "type": "text" } } } } '
curl -X PUT "localhost:9200/test/_doc/1" -H 'Content-Type: application/json' -d' { "query": { "query_string": { "query": "message:(xyz:abc)" } } } '
Error is expected:
{ "type": "query_shard_exception", "reason": "No field mapping can be found for the field with name [xyz]", "index": "test" }
curl -X PUT "localhost:9200/test/_doc/1" -H 'Content-Type: application/json' -d' { "query": { "query_string": { "query": "message:(xyz:\"abc\")" } } } '
Success is not expected:
{ "_index": "test", "_type": "_doc", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 1, "successful": 1, "failed": 0 }, "_seq_no": 0, "_primary_term": 1 }
Provide logs (if relevant):
The text was updated successfully, but these errors were encountered: