Skip to content

Instantly share code, notes, and snippets.

@kimchey
Last active December 11, 2015 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimchey/4520987 to your computer and use it in GitHub Desktop.
Save kimchey/4520987 to your computer and use it in GitHub Desktop.
Geo-Polygon Percolator
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