-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[BUG] Flattened Field exists Query Issue with Dotted Sub-Field Names #17069
Description
Describe the bug
We have encountered a discrepancy between Elasticsearch and OpenSearch when querying exists on flattened fields with dotted sub-field names.
related topic #11425
Related component
Search:Query Capabilities
To Reproduce
- Create an index with the following mapping:
PUT qiafan_test2
{
"mappings": {
"properties": {
"earth": {
"type": "flattened/flat_object" (ES/OS)
}
}
}
}
- Index a document:
POST qiafan_test2/_doc/1
{
"earth": {
"american.north": "what an amazing day"
}
}
- Run the following query:
GET qiafan_test2/_search
{
"query": {
"bool": {
"boost": 1,
"must": [
{
"bool": {
"should": [
{
"exists": {
"boost": 1,
"field": "earth.american.north"
}
},
{
"exists": {
"boost": 1,
"field": "american.north"
}
}
]
}
}
]
}
}
}
Expected behavior
The query should return the indexed document, as the field earth.american.north exists in the document.
Observed Behavior
In Elasticsearch (7.10): The query returns the expected document.
In OpenSearch (2.18): The query does not return any results.
Additional Details
Analysis
The issue appears to be related to how OpenSearch handles exists queries on flattened fields with dotted sub-field names. Specifically:
existsonearth.american.northdoes not behave as expected.- The behavior differs from
termqueries, where such fields work correctly, as it supported in this PR Fix parsing of flat object fields with dots in keys #11425 american.northis not supported.
Impact
We are migrating our service from Elasticsearch 7.10 to Opensearch. This behavior prevents certain queries from functioning correctly, potentially affecting applications relying on exists queries for flattened fields.
Request
We kindly request the community to investigate this issue. If this behavior is by design, clarification in the documentation would be helpful. If it is a bug, we hope for a fix or a recommended workaround.
Thank you for your assistance!
Metadata
Metadata
Assignees
Labels
Type
Projects
Status