Skip to content

Incorrect results of ES|QL query for point field nested in object #125710

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

Open
lkts opened this issue Mar 26, 2025 · 5 comments
Open

Incorrect results of ES|QL query for point field nested in object #125710

lkts opened this issue Mar 26, 2025 · 5 comments
Assignees
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@lkts
Copy link
Contributor

lkts commented Mar 26, 2025

Elasticsearch Version

9.1 and earlier

Installed Plugins

No response

Java Version

bundled

OS Version

Problem Description

If you create a document with an object array and a point field using array form inside, it is not possible to use such field in a ES|QL query. Using specifically an array form and having multiple values of the field is crucial for the reproduction. See the steps below. This also applies to geo_point.

Steps to Reproduce

PUT my-index
{
  "mappings": {
    "properties": {
      "top": {
        "properties": {
          "p": {
            "type": "point"
          }
        }
      }
    }
  }
}

POST my-index/_bulk?refresh
{ "create": {} }
{ "top": [{"p": [-71.34, 41.12]}, {"p": "POINT (-71.34 41.13)"}] }

POST /_query?format=txt
{
  "query": "FROM my-index"
}

Produces:

     top.p     
---------------
null           

But should produce:

                   top.p                    
--------------------------------------------
[POINT (-71.34 41.12), POINT (-71.34 41.13)]

Logs (if relevant)

No response

@lkts lkts added :Analytics/ES|QL AKA ESQL >bug needs:triage Requires assignment of a team area label labels Mar 26, 2025
@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) and removed needs:triage Requires assignment of a team area label labels Mar 26, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@lkts
Copy link
Contributor Author

lkts commented Mar 26, 2025

It seems that something is wrong somewhere in XContentMapValues#extractValue.

@luigidellaquila
Copy link
Contributor

@craigtaverner maybe you have a clue already? Otherwise I can try to debug it

@lkts
Copy link
Contributor Author

lkts commented Apr 1, 2025

There are tests in #125816 that reproduce this. They are commented out for now.

@astefan
Copy link
Contributor

astefan commented Apr 10, 2025

The problem seems related specifically to the array format of the point, not necessarily that field being an array.
I think there are three conditions for this to happen:

  • the field to be a sub-field
  • the field to have an array of values
  • the values in the array to have a mix of formats
{"index":{"_index":"test","_id":1}}
{ "top": [{"p": [-71.34, 41.12]}, {"p": "POINT (-71.34 41.13)"}],"ppp":[[-71.34, 41.12], "POINT (-71.34 41.13)"]}
{"index":{"_index":"test","_id":2}}
{ "top": {"p": [-71.34, 41.15]},"ppp":[-71.34, 41.12] }
{"index":{"_index":"test","_id":3}}
{ "top": [{"p": "POINT (-71.34 41.12)"}, {"p": "POINT (-71.34 41.13)"}],"ppp":["POINT (-71.34 41.12)", "POINT (-71.34 41.13)"] }
{"index":{"_index":"test","_id":4}}
{ "top": [{"p": [-71.34, 41.12]}, {"p": [-71.34, 41.13]}],"ppp":[[-71.34, 41.13], [-71.34, 41.12]] }
from test METADATA _source, _id | keep top.p, *
                   top.p                    |                    ppp                     |                                                  _source                                                   |      _id      
--------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------------------+---------------
null                                        |[POINT (-71.34 41.12), POINT (-71.34 41.13)]|{top=[{p=[-71.34, 41.12]}, {p=POINT (-71.34 41.13)}], ppp=[[-71.34, 41.12], POINT (-71.34 41.13)]}          |1              
POINT (-71.34 41.15)                        |POINT (-71.34 41.12)                        |{top={p=[-71.34, 41.15]}, ppp=[-71.34, 41.12]}                                                              |2              
[POINT (-71.34 41.12), POINT (-71.34 41.13)]|[POINT (-71.34 41.12), POINT (-71.34 41.13)]|{top=[{p=POINT (-71.34 41.12)}, {p=POINT (-71.34 41.13)}], ppp=[POINT (-71.34 41.12), POINT (-71.34 41.13)]}|3              
POINT (-71.34 41.12)                        |[POINT (-71.34 41.13), POINT (-71.34 41.12)]|{top=[{p=[-71.34, 41.12]}, {p=[-71.34, 41.13]}], ppp=[[-71.34, 41.13], [-71.34, 41.12]]}                    |4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

5 participants