# 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/18471>\
**Category:** Elasticsearch\
**Created:** [July 3, 2014, 6:36pm UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18471 "2014-07-03T18:36:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akun\_baru](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@akun\_baru](https://discuss.elastic.co/u/akun_baru)\
**Post date:** [July 3, 2014, 6:36pm UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18471/1 "2014-07-03T18:36:58Z")

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

COK -+)& Watch Chef 2014 Full Movie Online HD  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/cok-watch-chef-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/cok-watch-chef-2014-full-movie-online-hd/)  
[SILIT] ?$ Watch X-Men: Days of Future Past 2014 Full Movie Online Free  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/silit-watch-x-men-days-of-future-past-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/silit-watch-x-men-days-of-future-past-2014-full-movie-online-free/)  
[High] #)|/ Watch The Fault in Our Stars 2014 Full Movie Online 1080P  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/high-watch-the-fault-in-our-stars-2014-full-movie-online-1080p/](https://fullhdmovieonline21.wordpress.com/2014/07/03/high-watch-the-fault-in-our-stars-2014-full-movie-online-1080p/)  
[TUAY] +(}@ Watch Edge of Tomorrow 2014 Full Movie Online HD  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/tuay-watch-edge-of-tomorrow-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/tuay-watch-edge-of-tomorrow-2014-full-movie-online-hd/)  
[PRET] =][\> Watch Jersey Boys 2014 Full Movie Online 1080P  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/pret-watch-jersey-boys-2014-full-movie-online-1080p/](https://fullhdmovieonline21.wordpress.com/2014/07/03/pret-watch-jersey-boys-2014-full-movie-online-1080p/)  
[TIL] /}{( Watch Maleficent 2014 Full Movie Online HD  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/til-watch-maleficent-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/til-watch-maleficent-2014-full-movie-online-hd/)  
[CLEAR] &_?= Watch Think Like a Man Too 2014 Full Movie Online Free  
 [https://fullhdmovieonline21.wordpress.com/2014/07/03/clear-\_-watch-think-like-a-man-too-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/clear-_-watch-think-like-a-man-too-2014-full-movie-online-free/)  
[COMM] (|_$ Watch How to Train Your Dragon 2 2014 Full Movie Online Free  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/comm-\_-watch-how-to-train-your-dragon-2-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/comm-_-watch-how-to-train-your-dragon-2-2014-full-movie-online-free/)  
Joss &\<(# Watch 22 Jump Street 2014 Full Movie Online  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/joss-watch-22-jump-street-2014-full-movie-online/](https://fullhdmovieonline21.wordpress.com/2014/07/03/joss-watch-22-jump-street-2014-full-movie-online/)  
ASU @(\<{ Watch Transformers: Age of Extinction 2014 Full Movie Online  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-transformers-age-of-extinction-2014-full-movie-online/](https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-transformers-age-of-extinction-2014-full-movie-online/)  
ASU %/$] Watch Need for Speed 2014 Full Movie Online for Free  
[https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-need-for-speed-2014-full-movie-online-for-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-need-for-speed-2014-full-movie-online-for-free/)

--  
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/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 18, 2014, 9:26am UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18471/2 "2014-07-18T09:26:00Z")

</div>

Hey,

if you want to search shapes inside of shapes (where a point is a shape as  
well), you should use the geo\_shape type, not the geo\_point one. Also use  
the geo\_shape query and filters.

--Alex

On Thu, Jul 3, 2014 at 8:36 PM, akun baru [patihgajahmada01@gmail.com](mailto:patihgajahmada01@gmail.com)  
wrote:

> 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}  
> ]  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> COK -+)& Watch Chef 2014 Full Movie Online HD  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/cok-watch-chef-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/cok-watch-chef-2014-full-movie-online-hd/)  
> [SILIT] ?$ Watch X-Men: Days of Future Past 2014 Full Movie Online Free  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/silit-watch-x-men-days-of-future-past-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/silit-watch-x-men-days-of-future-past-2014-full-movie-online-free/)  
> [High] #)|/ Watch The Fault in Our Stars 2014 Full Movie Online 1080P  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/high-watch-the-fault-in-our-stars-2014-full-movie-online-1080p/](https://fullhdmovieonline21.wordpress.com/2014/07/03/high-watch-the-fault-in-our-stars-2014-full-movie-online-1080p/)  
> [TUAY] +(}@ Watch Edge of Tomorrow 2014 Full Movie Online HD  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/tuay-watch-edge-of-tomorrow-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/tuay-watch-edge-of-tomorrow-2014-full-movie-online-hd/)  
> [PRET] =][\> Watch Jersey Boys 2014 Full Movie Online 1080P  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/pret-watch-jersey-boys-2014-full-movie-online-1080p/](https://fullhdmovieonline21.wordpress.com/2014/07/03/pret-watch-jersey-boys-2014-full-movie-online-1080p/)  
> [TIL] /}{( Watch Maleficent 2014 Full Movie Online HD  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/til-watch-maleficent-2014-full-movie-online-hd/](https://fullhdmovieonline21.wordpress.com/2014/07/03/til-watch-maleficent-2014-full-movie-online-hd/)  
> [CLEAR] &_?= Watch Think Like a Man Too 2014 Full Movie Online Free  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/clear-\_-watch-think-like-a-man-too-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/clear-_-watch-think-like-a-man-too-2014-full-movie-online-free/)  
> [COMM] (|_$ Watch How to Train Your Dragon 2 2014 Full Movie Online Free  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/comm-\_-watch-how-to-train-your-dragon-2-2014-full-movie-online-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/comm-_-watch-how-to-train-your-dragon-2-2014-full-movie-online-free/)  
> Joss &\<(# Watch 22 Jump Street 2014 Full Movie Online  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/joss-watch-22-jump-street-2014-full-movie-online/](https://fullhdmovieonline21.wordpress.com/2014/07/03/joss-watch-22-jump-street-2014-full-movie-online/)  
> ASU @(\<{ Watch Transformers: Age of Extinction 2014 Full Movie Online  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-transformers-age-of-extinction-2014-full-movie-online/](https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-transformers-age-of-extinction-2014-full-movie-online/)  
> ASU %/$] Watch Need for Speed 2014 Full Movie Online for Free  
> [https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-need-for-speed-2014-full-movie-online-for-free/](https://fullhdmovieonline21.wordpress.com/2014/07/03/asu-watch-need-for-speed-2014-full-movie-online-for-free/)
> 
> --  
> 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/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a7fc5bcf-b05d-4a2f-a2b2-23972bcea485%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGCwEM-1cCbH%3D\_H-xF6tEJkm0q2Mb-qAPuF3rgZar86CVUJD\_w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-1cCbH%3D_H-xF6tEJkm0q2Mb-qAPuF3rgZar86CVUJD_w%40mail.gmail.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:15am UTC](https://discuss.elastic.co/t/how-to-search-the-records-with-locations-all-in-a-polygon-or-multipolygon/18471/3 "2017-07-06T01:15:00Z")

</div>


