7
votes

Trying to build search as follows:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "geo_distance": {
          "distance": "50km",
          "coordinates": {
            "lat": 52.5234051,
            "lon": 4.113999
          }
        }
      }
    }
  }
}

where coordinates is of type 'geo_point'.

But when I try to run this query, the elasticsearch.log pops up with an error: [locations] failed to find geo_point field [coordinates]

Edit:

This is part of the /locations/location/_mapping:

{
  "locations": {
  "mappings": {
  "location": {
  "properties": {
    ...
    "coordinates": {
      "properties": {
        "lat": {
          "type": "string"
         },
        "lon": {
          "type": "string"
        }
      }
    },
   ...
 }
}

Any ideas what is wrong here?

1
What us the field name of geo point??BlackPOP
@BlackPOP: see edit of original postaxel freudiger
I think you didint use geo_point in mapping.. refer this elasticsearch.org/guide/en/elasticsearch/reference/current/…BlackPOP
@BlackPOP You are right. I accidentally wrote the mapping but didn't apply it. Works now. Thx.axel freudiger
I have same problem when I check the mapping field in Management > index pattern , the mapping is geo_point and it is correct but when I write query GET theIndex/_mapping/ in dev tools is "location": { "properties": { "lat": { "type": "float" }, "lon": { "type": "float" } } },saba safavi

1 Answers

11
votes

The problem is mapping.you need to use geo_point in mapping.. refer this .