Skip to content
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

geo_shape 'within' query regression in 6.6 #40085

Closed
MohamedHamouGisaia opened this issue Mar 15, 2019 · 3 comments
Closed

geo_shape 'within' query regression in 6.6 #40085

MohamedHamouGisaia opened this issue Mar 15, 2019 · 3 comments
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v6.6.0

Comments

@MohamedHamouGisaia
Copy link

MohamedHamouGisaia commented Mar 15, 2019

Elasticsearch version
Version: 6.6.1, Build: default/zip/1fd8f69/2019-02-13T17:10:04.160291Z, JVM: 1.8.0_181

Plugins installed:
None

JVM version :
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

OS version
Linux tizintest 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
I indexed (with BKD-tree indexation) 4 shapes which coordinates are :
P1 : [ [ 3, 4 ], [ 4, 4 ], [ 4, 3 ], [ 3, 3 ], [ 3, 4 ] ]
P2 : [ [ 6, 2 ], [ 7, 2 ], [ 7, 1 ], [ 6, 1 ], [ 6, 2 ] ]
P3 : [ [ 3, 1 ], [ 4, 1 ], [ 4, 0 ], [ 3, 0 ], [ 3, 1 ] ]
P4 : [ [ 0, 2 ], [ 1, 2 ], [ 1, 1 ], [ 0, 1 ], [ 0, 2 ] ]

image

Querying all the shapes that are within the dashed polygon only returns polygons P1 and P2
The four polygons are returned in 6.5
(dashed polygon coordinates : [ [ 0, 4 ], [ 7, 4 ], [ 7, 0 ], [ 0, 0 ], [ 0, 4 ] ])

Steps to reproduce:

  1. Index creation
curl -X PUT "localhost:9200/test_index" -H 'Content-Type: application/json' -d'
{
    "mappings": {
        "_doc": {
            "properties": {
                "location": {
                    "type": "geo_shape"
                }
            }
        }
    }
}
'
  1. Indexing polygons (here P1 only)
curl -X POST "localhost:9200/test_index/_doc?refresh" -H 'Content-Type: application/json' -d'
{
    "location": {
    "type": "Polygon",
    "coordinates": [
      [ [ 3, 4 ], [ 4, 4 ], [ 4, 3 ], [ 3, 3 ], [ 3, 4 ] ]
    ]
  }
}
'
  1. Querying all the shapes that are within the dashed polygon
curl -X GET "localhost:9200/test_index/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "geo_shape": {
      "location": {
        "shape": {
          "type": "Polygon",
          "coordinates": [[[0, 4], [7, 4], [7, 0], [0, 0], [0, 4]]]
        },
        "relation": "within"
      }
    }
  }
}
'
@MohamedHamouGisaia MohamedHamouGisaia changed the title geo_shape within query regression in 6.6 geo_shape 'within' query regression in 6.6 Mar 15, 2019
@martijnvg martijnvg added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Mar 15, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@nknize
Copy link
Contributor

nknize commented Mar 22, 2019

I've opened LUCENE-8736 to address this issue.

tldr: The problem is related to how the "crossing number" and "winding number" methods for detecting vertex containment (point in polygon) and edge crossings are applied in the triangle relation computation.

@nknize
Copy link
Contributor

nknize commented Jul 8, 2020

Fixed as of Lucene 8.4 release.

@nknize nknize closed this as completed Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v6.6.0
Projects
None yet
Development

No branches or pull requests

6 participants