Last active
December 11, 2015 01:08
-
-
Save kimchey/4520987 to your computer and use it in GitHub Desktop.
Geo-Polygon Percolator
This file contains hidden or 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
1) Here is the mapping: | |
curl -XGET localhost:9200/listing/listing/_mapping | |
{"listing":{"properties":{"address":{"type":"string"}, | |
"id":{"type":"string"}, | |
"location":{"type":"geo_point"} | |
}}} | |
2)This is my percolator query: | |
curl -X PUT localhost:9200/_percolator/listing/q1str2?pretty -d ' | |
{"query": | |
{"filtered": | |
{"query": {"match_all": {}}, | |
"filter": | |
{"and": | |
[{"and": | |
[ | |
{"geo_polygon": { | |
"location": { | |
"points": [ | |
{"lat" : 34.98123, "lon" : -90.35156}, | |
{"lat" : 36.47944, "lon" : -90.26367}, | |
{"lat" : 36.76161, "lon" : -84.63867}, | |
{"lat" : 34.83708, "lon" : -84.81445} | |
] | |
} | |
} | |
} | |
]}]}}} | |
}' | |
3) I now get results from percolating this document: | |
curl -XGET localhost:9200/listing/listing/_percolate -d ' | |
{ | |
"doc": { | |
"location" : { | |
"lat" : 35.48377, | |
"lon" : -88.85742 | |
} | |
} | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment