I have documents in ES that have a "boundaries" field. This is an example of the contents of the field: https://gist.github.com/litzinger/a95342dedc0081c8db8d
Given a lon/lat point, I need to be able to query this index to find which document(s) that point falls within. I'm having trouble constructing this query and can't seem to find a clear cut example of how to do this anywhere.
This is an example of one of my queries in which the coordinates array is the lon/lat point. I already have a working query that will use a polygon to find all documents that have a lon/lat point, but I can't seem to get it to work the other way around.
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"boundaries": {
"relation": "intersects",
"shape": {
"coordinates": [
[
[-96.960876,32.795025]
]
],
"type": "point"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
Figured it out. First, my mapping was wrong. The field was called "boundary" not "boundaries". Oops. Second, the coordinates value was wrong. Search query should be:
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"boundaries": {
"relation": "intersects",
"shape": {
"coordinates": [
-96.960876,
32.795025
],
"type": "point"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With