How to search the records with locations all in a polygon or multiPolygon?


(binque) #1

I add the mappings and insert a record with 2 locations ([13, 13], [52, 52]),
and I want to search the results with it's locations all in the polygon,not one of the locations in the polygon. would you please tell me how to search the reslut?

curl -XPOST localhost:9200/test5 -d '{
"mappings" : {
"gistype" : {
"properties" : {
"address":{
"properties":{
"location":{"type" : "geo_point"}
}
}
}
}
}
}'

curl -XPUT 'http://localhost:9200/test5/gistype/1' -d '{
"name": "Wind & Wetter, Berlin, Germany",
"address": [
{
"name":1,
"location": [13, 13]
},
{
"name":2,
"location": [52, 52]
}
]
}'

I searched like this , but I want to search the record locations all in the polygon. So it's wrong .

curl -XGET 'http://localhost:9200/test5/gistype/_search?pretty=true' -d '{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 0, "lon" : 0},
{"lat" : 14, "lon" : 0},
{"lat" : 14, "lon" : 14},
{"lat" : 0, "lon" : 14}
]
}
}
}
}
}
}'


(binque) #2

@kimchy


(system) #3