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 query on geo_shape field of type point with points_only set to true does not work in 6.x #28744

Closed
znanev opened this issue Feb 20, 2018 · 3 comments

Comments

@znanev
Copy link

commented Feb 20, 2018

Elasticsearch version (bin/elasticsearch --version):
Version: 6.2.1, Build: 7299dc3/2018-02-07T19:34:26.990113Z, JVM: 1.8.0_161

Plugins installed: None

JVM version (java -version):
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux node1 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
geo_shape query on geo_shape field of type point with points_only set to true does not work anymore in 6.x. It was working correctly in 5.x. By not working I mean when querying for points contained within a geo_shape (envelope, polygon etc.), no hits are returned. When points_only: true is removed from mapping, the queries work as expected, returning the points contained within the specified geo_shape.

Steps to reproduce:

Basically using the examples in https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html. The only difference is specifying points_only: true in the location field, as shown below:

  1. Create an index to store some points:
PUT /example
{
    "mappings": {
        "_doc": {
            "properties": {
                "location": {
                    "type": "geo_shape",
                    "points_only": true
                }
            }
        }
    }
}
  1. Store a point
POST /example/_doc?refresh
{
    "name": "Wind & Wetter, Berlin, Germany",
    "location": {
        "type": "point",
        "coordinates": [13.400544, 52.530286]
    }
}
  1. The following query should find the point using the Elasticsearch’s envelope GeoJSON extension:
GET /example/_search
{
    "query":{
        "bool": {
            "must": {
                "match_all": {}
            },
            "filter": {
                "geo_shape": {
                    "location": {
                        "shape": {
                            "type": "envelope",
                            "coordinates" : [[13.0, 53.0], [14.0, 52.0]]
                        },
                        "relation": "within"
                    }
                }
            }
        }
    }
}

But in fact it returns no hits:

{
   "took": 0,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "skipped": 0,
      "failed": 0
   },
   "hits": {
      "total": 0,
      "max_score": null,
      "hits": []
   }
}

If you delete the example index and create it without specifying points_only: true, as follows:

PUT /example
{
    "mappings": {
        "_doc": {
            "properties": {
                "location": {
                    "type": "geo_shape"
                }
            }
        }
    }
}

and repeat steps 2 and 3 above, the query will return the point, as expected:

{
   "took": 0,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "skipped": 0,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "example",
            "_type": "_doc",
            "_id": "SZods2EBpb50aY-UDsK9",
            "_score": 1,
            "_source": {
               "name": "Wind & Wetter, Berlin, Germany",
               "location": {
                  "type": "point",
                  "coordinates": [
                     13.400544,
                     52.530286
                  ]
               }
            }
         }
      ]
   }
}
@albertzaharovits

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2018

@elastic/es-search-aggs

@colings86

This comment has been minimized.

Copy link
Member

commented Feb 20, 2018

@nknize could you take a look?

@brianMeskill

This comment has been minimized.

Copy link

commented Feb 21, 2018

I was just going to open the same bug.

Some further info that might help: this is not an issue in 6.0.1 but I've reproduced it in subsequent versions including 6.1.0 and 6.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.