ElasticSearch and geo_point not working as I expect. What I'm doing wrong?


(Diego) #1

Hey guys. I have an elastic search instance and I indexing events with location. My mapping is:

{
  "mappings": {
    "event": {
      "properties": {
        "id": { "type": "long", "index": "not_analyzed" },
        "name": {"type": "string"},
        "description": {"type": "string",},
        "start_date":   { "type": "date" },
        "end_date":     { "type": "date" },
        "coordinates":  { "type": "geo_point" }
      }
    }
  }
}

Then I search for event close to me using this query:

{
	"sort": [
		{
			"_geo_distance": {
				"distance_type": "plane",
				"unit": "km",
				"coordinates": {"lat": -21.1726736, "lon": -47.8594995},
				"order": "asc"
			}
		}
	],
	"query": {
		"filtered": {
			"filter": {
				"bool": {
					"must": [
						{"range": {"end_date": {"gt": "2016-11-29T11:36:27-02:00"}}},
						{"term": {"is_published": true}},
						{"term": {"is_private": false}},
						{"term": {"is_cancelled": false}},
						{"term": {"is_closed": false}}
					]
				}
			}
		}
	},
	"size": 15,
	"from": 0
}

Then, when I inspect the result to see the distance of the event from the coordinates that I send, I got this:

[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]
[1.7976931348623157e+308]

All distances are TOO BIG, even when the event is kind of close of the point that I send.

What I'm doing wrong here?

Thanks in advance.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.