Different formats of geo_point type


(Tule) #1

From the documentation here: http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

It says geo_point accept different format. Ex: these two are supported

  1. "location" : "41.12,-71.34"
  2. "location" : {
    "lat" : 41.12,
    "lon" : -71.34
    }

I want to ask if these two are the same?
I'm using ES 0.17.6 and having this problem:
When I index using the (1) format, I can't search with (2) format. If
I use (1) again, it is successful.

How I index:
curl -XPUT 'http://localhost:9200/twitter/pin/1' -d '
{
"pin" : {
"location" : {
lat: 41.12,
lon: -71.34
},
"tag" : ["food", "family"],
"text" : "my favorite family restaurant"
}
}'

and how I search:
curl -XGET 'http://localhost:9200/twitter/pin/_search' -d '
{
"query": {
"filtered" : {
"query" : {
"field" : { "text" : "restaurant" }
},
"filter" : {
"geo_distance" : {
"distance" : "12km",
"pin.location" : "-71.34, 41.12"
}
}
}
}
}
'


(Igor Motov) #2

Answered on
stackoverlflow http://stackoverflow.com/questions/10577251/different-formats-of-geo-point-type

On Friday, May 11, 2012 10:54:35 PM UTC-4, Tule wrote:

From the documentation here:
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

It says geo_point accept different format. Ex: these two are supported

  1. "location" : "41.12,-71.34"
  2. "location" : {
    "lat" : 41.12,
    "lon" : -71.34
    }

I want to ask if these two are the same?
I'm using ES 0.17.6 and having this problem:
When I index using the (1) format, I can't search with (2) format. If
I use (1) again, it is successful.

How I index:
curl -XPUT 'http://localhost:9200/twitter/pin/1' -d '
{
"pin" : {
"location" : {
lat: 41.12,
lon: -71.34
},
"tag" : ["food", "family"],
"text" : "my favorite family restaurant"
}
}'

and how I search:
curl -XGET 'http://localhost:9200/twitter/pin/_search' -d '
{
"query": {
"filtered" : {
"query" : {
"field" : { "text" : "restaurant" }
},
"filter" : {
"geo_distance" : {
"distance" : "12km",
"pin.location" : "-71.34, 41.12"
}
}
}
}
}
'


(system) #3