How to find documents containing polygons point by point?
I have documents in ES that have a "borders" field. This is a sample field content: https://gist.github.com/litzinger/a95342dedc0081c8db8d
Given the lon / lat point, I need to be able to query that index to find which document is at that point. I'm having trouble building this query and can't seem to find a clear example of how to do this.
This is an example of one of my queries where the coordinate 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 cannot 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": {}
}
}
}
}
source to share
Found it out. First, my mapping was wrong. The field was called "border", not "borders". Unfortunately. Second, the coordinates were incorrect. The search query should be:
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"boundaries": {
"relation": "intersects",
"shape": {
"coordinates": [
-96.960876,
32.795025
],
"type": "point"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
source to share