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
Inconsistent behaviour for matched_queries
field
#101480
Comments
8.10.4 shows the same behaviour. Documentation doesn't clarify whether names should be unique or not: https://www.elastic.co/guide/en/elasticsearch/reference/8.10/query-dsl-bool-query.html#named-queries |
Pinging @elastic/es-search (Team:Search) |
I verified via a test:
Digging into the code, we assume query names are to be unique. Any duplicate names will result in undefined behavior as the It has been this way for as long back as I can see in the source. I will add something in the docs explaining this. Makes me wonder if we should throw an exception if duplicate query names are detected. |
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
…s undefined (elastic#101523) relates to: elastic#101480
Disallowing duplicate Closing this issue as we documented that sending duplicate _names is results in undefined behavior. |
Elasticsearch Version
7.17.5
Installed Plugins
No response
Java Version
bundled
OS Version
Linux 69c04e0415e4 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
Problem Description
matched_queries
field is not populated formatch
query whenshould
clause includesmatch
andmatch_bool_prefix
with the same name.Steps to Reproduce
{ "dynamic": false, "properties": { "id": { "type": "keyword" }, "names": { "type": "text" } } }
{ "id": "1", "names": ["BALTAS"] }
,{ "id": "2", "names": [" alias", " Test alias"] }
{ "query": { "bool": { "should": [ { "match": { "names": { "query": "BALTAS", "operator": "AND", "fuzziness": "AUTO", "prefix_length": 0, "max_expansions": 50, "fuzzy_transpositions": true, "lenient": false, "zero_terms_query": "NONE", "auto_generate_synonyms_phrase_query": true, "_name": "names" } } }, { "match_bool_prefix": { "names": { "query": "BALTAS", "operator": "AND", "prefix_length": 0, "max_expansions": 50, "fuzzy_transpositions": true, "_name": "names" } } } ] } } }
matched_queries
for the document with"id": "2"
result{ "took": 11, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 2, "relation": "eq" }, "max_score": 1.8713851, "hits": [{ "_index": "named_queries", "_type": "_doc", "_id": "U6lqcosBGtR7NdaKQuTo", "_score": 1.8713851, "_source": { "id": "1", "names": ["BALTAS"] }, "matched_queries": ["names"] }, { "_index": "named_queries", "_type": "_doc", "_id": "VKlqcosBGtR7NdaKh-Qq", "_score": 0.5013448, "_source": { "id": "2", "names": [" alias", " Test alias"] } }] } }
match
query tonames1
matched_queries
works as expectedmatch
querymatched_queries
works as expectedLogs (if relevant)
No response
The text was updated successfully, but these errors were encountered: