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

**URL:** <https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18430>\
**Category:** Elasticsearch\
**Created:** [July 2, 2014, 6:36am UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18430 "2014-07-02T06:36:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11156](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/11156/32/1440_2.png) [@11156](https://discuss.elastic.co/u/11156)\
**Post date:** [July 2, 2014, 6:36am UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18430/1 "2014-07-02T06:36:11Z")

</div>

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](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](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}  
]  
}  
}  
}  
}  
}  
}'

@kimchy

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5d156505-9695-4315-8826-884d8e4f1f8e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5d156505-9695-4315-8826-884d8e4f1f8e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:18am UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18430/2 "2017-07-06T01:18:32Z")

</div>


