elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.41k stars 24.56k forks source link

[ESQL] Spatial functions pushed down to lucene produce different results for multi-values #110830

Open iverase opened 1 month ago

iverase commented 1 month ago

Currently the compute engine return false when executing a spatial function with multivalues but if the function is pushed down to lucene, then the relationship is computed as it the multivalues is a Geometry collection. These means the results might be different depending on a function being pushed down to lucene or not.

This can be reproduced with the following commands:


PUT indexed
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

PUT not_indexed
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point",
        "index": false,
        "doc_values": false
      }
    }
  }
}

POST indexed/_doc 
{
  "location" : ["POINT(0 0)", "POINT(180 0)"]
}

POST not_indexed/_doc 
{
  "location" : ["POINT(0 0)", "POINT(180 0)"]
}

POST _query 
{
  "query" : """
  FROM indexed | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POINT(0 0)")) 
  """
}

POST _query 
{
  "query" : """
  FROM not_indexed | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POINT(0 0)")) 
  """
}

The results of the queries should be the same regardless of how the field is defined in the mappings.

elasticsearchmachine commented 1 month ago

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