Geo Distance Filter with ElasticSearch Always Returns 0 Results

I use Geo Distance Filter with ElasticSearch and no matter what distance I look for, elasticsearch 0.90.11 returns zero results.

Here's what I did: first, delete / create a new index with a geographic mapping:

curl -XDELETE 'http://localhost:9200/photos'

curl -XPOST 'http://localhost:9200/photos' -d '
{
  "mappings": {
    "pin" : {
        "properties" : {
            "location" : {
                "type" : "geo_point"
            }
        }
    }
  }
}
'

Then add the document:

curl -XPOST 'http://localhost:9200/photos/photo?pretty=1' -d '
{
   "pin" : {
      "location" : {
         "lat" : 46.8,
         "lon" : -71.2
      }
   },
   "file" : "IMG_2115.JPG"
}
'

Then do a search:

curl -XGET 'http://localhost:9200/photos/_search?pretty=1&size=20' -d '
{
   "query" : {
      "match_all" : {}
   },
   "filter" : {
      "geo_distance" : {
         "distance" : "10km",
         "pin.location" : {
            "lat" : "46.8",
            "lon" : "-71.2"
         }
      }
   }
}
'

But the search yields null images:

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

- , ? , "" , "", "" , , , , , , "" "" json-.

...

+3
1

, ,

[Sun Feb  9 11:01:55 2014] # Request to: http://localhost:9200
curl -XPUT 'http://localhost:9200/photos?pretty=1' -d '
{
   "mappings" : {
      "photo" : {
         "properties" : {
            "Location" : {
               "type" : "geo_point"
            }
         }
      }
   }
}
'

GPS :

[Sun Feb  9 11:01:56 2014] # Request to: http://localhost:9200
curl -XPOST 'http://localhost:9200/photos/photo?pretty=1' -d '
{
   "file" : "/home/mschilli/iphone/IMG_2115.JPG",
   "Location" : [
      46.8,
      -71.2
   ]
}
'

[Sun Feb  9 11:05:00 2014] # Request to: http://localhost:9200
curl -XGET 'http://localhost:9200/photos/_search?pretty=1&size=100' -d '
{
   "filter" : {
      "geo_distance" : {
         "distance" : "1km",
         "Location" : [
            36.986,
            -121.443333333333
         ]
      }
   },
   "query" : {
      "match_all" : {}
   }
}
'

, GPS.

+6

All Articles