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

Documents outside geoshape query are returned #27123

Closed
arko-r opened this issue Oct 26, 2017 · 1 comment
Closed

Documents outside geoshape query are returned #27123

arko-r opened this issue Oct 26, 2017 · 1 comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes

Comments

@arko-r
Copy link

arko-r commented Oct 26, 2017

I have a geoshape query which returns more documents than it should.
Some of the documents are outside of the coordinates specified in the query.

The query specifies a latitude between 54 and 55, but in the results documents with a latitude of 55.01 are also returned (longitude is inside specified coordinate range).
However searching for a longitude between -8 and 9, a longitude of 9.01 is not included in the results (latitude is inside specified coordinate range)

Did I miss something what causes the document with latitude 55.01 to be returned, or is this a bug?

Elasticsearch version: 6.0.0-rc1
JVM version: 1.8.0_144
OS version: Windows 10

Steps to reproduce:
Mapping
curl -XPUT "http://localhost:9200/test" -H 'Content-Type: application/json' -d' {"settings":{"number_of_shards":1,"number_of_replicas":0},"mappings":{"value":{"properties":{"location":{"type":"geo_shape"}}}}}'
Data
curl -XPOST "http://localhost:9200/_bulk" -H 'Content-Type: application/json' -d' {"index":{"_index":"test","_type":"value"}} {"location":{"type":"point","coordinates":[54.999,7.497]}} {"index":{"_index":"test","_type":"value"}} {"location":{"type":"point","coordinates":[55,7.497]}} {"index":{"_index":"test","_type":"value"}} {"location":{"type":"point","coordinates":[55.01,8.2]}} {"index":{"_index":"test","_type":"value"}} {"location":{"type":"point","coordinates":[54.5,9.01]}} {"index":{"_index":"test","_type":"value"}} {"location":{"type":"point","coordinates":[54.5,9.01]}} '
Query
curl -XGET "http://localhost:9200/test/_search" -H 'Content-Type: application/json' -d' {"query":{"bool":{"must":{"match_all":{}},"filter":{"geo_shape":{"location":{"shape":{"type":"envelope","coordinates":[[55,-8],[54,9]]},"relation":"within"}}}}}}'

@cbuescher cbuescher added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Oct 26, 2017
@DaveCTurner
Copy link
Contributor

@arko-r thanks for providing a small reproduction for your issue. The bulk request got a little mangled but I can reproduce it.

This is expected behaviour as noted in https://www.elastic.co/guide/en/elasticsearch/reference/6.0/geo-shape.html#_accuracy and due to the way that Elasticsearch indexes geoshapes:

Geo_shape does not provide 100% accuracy and depending on how it is configured it may return some false positives or false negatives for certain queries. To mitigate this, it is important to select an appropriate value for the tree_levels parameter and to adjust expectations accordingly.

If you require more accuracy, please configure your mapping appropriately using the precision and distance_error_pct parameters.

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
Projects
None yet
Development

No branches or pull requests

3 participants