Created
April 17, 2012 15:34
-
-
Save anonymous/2406859 to your computer and use it in GitHub Desktop.
ElasticSearch geo distance filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//i create doc item using Elastica in PHP, database has about 150 000 items | |
$mapping->setProperties( | |
array( | |
'id' => array('type' => 'integer'), | |
'name' => array('type' => 'string'), | |
'quality' => array('type' => 'integer'), | |
'type_id' => array('type' => 'integer'), | |
'country' => array('type' => 'string'), | |
'city' => array('type' => 'integer'), | |
'location' => array('type' => 'geo_point') | |
) | |
); | |
//i use curl lib in PHP, in common the query is following: | |
curl -XGET "http://localhost:9200/database/object/_search" -d ' | |
{ "size" : 2000, | |
"filter" : { | |
"geo_distance" : { | |
"distance" : "4km", | |
"location" : [48.85341, 2.3488], | |
"optimize_bbox" : "none", | |
"distance_type" : "arc" | |
} | |
}' | |
//returns 789 items | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment