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 point on the edges of the bounding box not considered? #29196

Closed
mloho opened this issue Mar 21, 2018 · 4 comments
Closed

Geo point on the edges of the bounding box not considered? #29196

mloho opened this issue Mar 21, 2018 · 4 comments
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >docs General docs changes

Comments

@mloho
Copy link

mloho commented Mar 21, 2018

Elasticsearch server version: {"number": "5.6.6","lucene_version": "6.6.1"}
Elasticsearch client version: 6.2.1

Plugins installed: [{ "name": "x-pack", "version": "5.6.6", "description": "Elasticsearch Expanded Pack Plugin", "classname": "org.elasticsearch.xpack.XPackPlugin", "has_native_controller": true }]

JVM version: 1.8.0_151

OS version: Linux ubuntu 4.4.0-116-generic

Steps to reproduce

  1. Document has a geo point field like so: "Location":[-83.106,28]
  2. Java-API-generated query contains a geo bounding box filter like so:
{
  "geo_bounding_box": {
    "Location": {
      "top_left": [
        -83.106,
        28
      ],
      "bottom_right": [
        -80.106,
        27
      ]
    },
    "validation_method": "STRICT",
    "type": "MEMORY",
    "ignore_unmapped": false,
    "boost": 1
  }
}

Expected
The query returns my document.

Actual
The query returns nothing. The query contains other filters but they do not interfere with the results because once I change the top value of the top_level field of the geo bounding box filter to -83.107, the document gets returned.

Observations & Questions

  • The same quirk can also be seen with the longitude value. If I change 28 and 27 to 29 and 28, I get nothing.
  • I can find no documentation to back up our initial assumption that the bounding box filter would be inclusive all around. Is the query supposed to return the document if its geo point exists on any of the edges of the bounding box?
@mloho mloho changed the title Geo Bounding Box: Geo point on the edges of the bounding box not considered? Mar 21, 2018
@jbaiera jbaiera added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Mar 21, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@colings86 colings86 added the >bug label Apr 24, 2018
@colings86
Copy link
Contributor

@nknize could you take a look at this one?

@imotov
Copy link
Contributor

imotov commented May 10, 2018

The current implementation in lucene excludes edges most of the time due to the way rounding is implemented. Basically, the query in the example is converted into:

GET /test/_validate/query?explain
{
  "query": {
    "geo_bounding_box": {
      "Location": {
        "top_left": [
          -83.106,
          28
        ],
        "bottom_right": [
          -80.106,
          27
        ]
      },
      "validation_method": "STRICT",
      "type": "MEMORY",
      "ignore_unmapped": false,
      "boost": 1
    }
  }
}
{
  "valid": true,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "explanations": [
    {
      "index": "test",
      "valid": true,
      "explanation": "Location:[27.00000002514571 TO 27.999999965541065],[-83.10599997639656 TO -80.10600007139146]"
    }
  ]
}

As far as I can see this is intentional (although undocumented) behaviour. Should we convert this into a documentation issue? @nknize, @jpountz what do you think?

@imotov imotov assigned imotov and unassigned nknize May 10, 2018
@imotov
Copy link
Contributor

imotov commented May 11, 2018

Discussed this with @jpountz. This is indeed an intended behavior introduced in LUCENE-7166. Geopoints have limited precision and as a result they are rounded. Geopoints are always rounded down during index time. During the query time upper boundaries of the bounding boxes are rounded down, while lower boundaries are rounded up. As a result the points along on the lower bounds (bottom and left edges of the bounding box) might not make it into the bounding box due to the rounding error.

I am going to change this issue to documentation issue and add some clarification to docs.

@imotov imotov added >docs General docs changes and removed >bug labels May 11, 2018
imotov added a commit to imotov/elasticsearch that referenced this issue May 11, 2018
The geo_bounding_box query might produce false positives alongside
the right and upper edges and false negatives alongside left and
bottom edges. This commit documents the behavior and defines the
maximum error.

Closes elastic#29196
imotov added a commit that referenced this issue May 14, 2018
The geo_bounding_box query might produce false positives alongside
the right and upper edges and false negatives alongside left and
bottom edges. This commit documents the behavior and defines the
maximum error.

Closes #29196
imotov added a commit that referenced this issue May 14, 2018
The geo_bounding_box query might produce false positives alongside
the right and upper edges and false negatives alongside left and
bottom edges. This commit documents the behavior and defines the
maximum error.

Closes #29196
imotov added a commit that referenced this issue May 14, 2018
The geo_bounding_box query might produce false positives alongside
the right and upper edges and false negatives alongside left and
bottom edges. This commit documents the behavior and defines the
maximum error.

Closes #29196
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 >docs General docs changes
Projects
None yet
Development

No branches or pull requests

6 participants