Geo location mapping and query

Hi,

I've created an index with the mapping below (I'm using pyes, but I
reproduced the steps with curl) and I can't get the geo query to
return any results. Please let me know what I'm doing wrong.

  1. create index and mapping

curl -XPUT 'localhost:9200/locations_index'

curl -XPUT 'http://localhost:9200/locations_index/location/_mapping' -d '
{
"location":{
"properties":{
"longId":{
"type":"long",
"store":"yes"
},
"id":{
"include_in_all":"false",
"index":"not_analyzed",
"type":"string",
"store":"yes"
},
"pin":{
"type":"geo_point",
"store":"yes"
}
}
}
}'

  1. populate index

curl -XPUT 'http://localhost:9200/locations_index/location/rd_1700' -d '
{
"longId": 1700,
"id": "id_1700",
"pin": {
"lat": 40.740000000000002,
"lon": 73.989999999999995
}
}'

  1. run a geo query

curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "10km",
"pin": {
"lat": 40.74,
"lon": -73.99
}
}
}
}
}
}'

I can see the document I index via the head plugin, but I the query
doesn't return it.

It returns:
{
"took":16,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":0,
"max_score":null,
"hits":[

  ]

}
}

Thank you

Look at the longitude you've indexed versus the one you are search for. Fix
that error and this query should work fine.

On Friday, March 16, 2012 6:55:27 PM UTC-4, Dragan wrote:

Hi,

I've created an index with the mapping below (I'm using pyes, but I
reproduced the steps with curl) and I can't get the geo query to
return any results. Please let me know what I'm doing wrong.

  1. create index and mapping

curl -XPUT 'localhost:9200/locations_index'

curl -XPUT 'http://localhost:9200/locations_index/location/_mapping' -d '
{
"location":{
"properties":{
"longId":{
"type":"long",
"store":"yes"
},
"id":{
"include_in_all":"false",
"index":"not_analyzed",
"type":"string",
"store":"yes"
},
"pin":{
"type":"geo_point",
"store":"yes"
}
}
}
}'

  1. populate index

curl -XPUT 'http://localhost:9200/locations_index/location/rd_1700' -d '
{
"longId": 1700,
"id": "id_1700",
"pin": {
"lat": 40.740000000000002,
"lon": 73.989999999999995
}
}'

  1. run a geo query

curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "10km",
"pin": {
"lat": 40.74,
"lon": -73.99
}
}
}
}
}
}'

I can see the document I index via the head plugin, but I the query
doesn't return it.

It returns:
{
"took":16,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":0,
"max_score":null,
"hits":[

  ]

}
}

Thank you

Thank you Eric!

On Saturday, March 17, 2012 7:59:42 AM UTC-4, egaumer wrote:

Look at the longitude you've indexed versus the one you are search for.
Fix that error and this query should work fine.

On Friday, March 16, 2012 6:55:27 PM UTC-4, Dragan wrote:

Hi,

I've created an index with the mapping below (I'm using pyes, but I
reproduced the steps with curl) and I can't get the geo query to
return any results. Please let me know what I'm doing wrong.

  1. create index and mapping

curl -XPUT 'localhost:9200/locations_index'

curl -XPUT 'http://localhost:9200/locations_index/location/_mapping' -d '
{
"location":{
"properties":{
"longId":{
"type":"long",
"store":"yes"
},
"id":{
"include_in_all":"false",
"index":"not_analyzed",
"type":"string",
"store":"yes"
},
"pin":{
"type":"geo_point",
"store":"yes"
}
}
}
}'

  1. populate index

curl -XPUT 'http://localhost:9200/locations_index/location/rd_1700' -d '
{
"longId": 1700,
"id": "id_1700",
"pin": {
"lat": 40.740000000000002,
"lon": 73.989999999999995
}
}'

  1. run a geo query

curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "10km",
"pin": {
"lat": 40.74,
"lon": -73.99
}
}
}
}
}
}'

I can see the document I index via the head plugin, but I the query
doesn't return it.

It returns:
{
"took":16,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":0,
"max_score":null,
"hits":[

  ]

}
}

Thank you