# Search document with multi geo\_point

**URL:** <https://discuss.elastic.co/t/search-document-with-multi-geo-point/22510>\
**Category:** Elasticsearch\
**Created:** [March 4, 2015, 10:52am UTC](https://discuss.elastic.co/t/search-document-with-multi-geo-point/22510 "2015-03-04T10:52:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean\_Szabo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean_szabo/32/853_2.png) [@Jean\_Szabo](https://discuss.elastic.co/u/Jean_Szabo)\
**Post date:** [March 4, 2015, 10:52am UTC](https://discuss.elastic.co/t/search-document-with-multi-geo-point/22510/1 "2015-03-04T10:52:44Z")

</div>

We have some offers with multiple adresse (geo\_point), and we wan't to  
search all adress around x km...

Actualy, we retrieve correct offers but with all geo\_point, and no just  
corresponding geo\_point.

Is it possible with nested object, without use parent/child ?

The other solution is to create a type localisations, with all adress and  
some offers informations and make our query in this type, is it the better  
solution ?

thanks

Jean

our tests :

DELETE /test/

POST /test/  
{  
"settings" : {  
"number\_of\_shards" : 1  
},  
"mappings" : {  
"offres" : {  
"\_source" : { "enabled" : true },  
"properties" : {  
"title" : { "type" : "string" },  
"locations" : {  
"type" : "nested",  
"include\_in\_parent": true,  
"properties": {  
"position": {  
"type": "geo\_point",  
"store": true  
},  
"addresse": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
}  
POST /test/offres/1  
{  
"title" : "offre 1",  
"locations" : {  
"addresse" : "Grand-Rue 33, 1302 Vufflens-la-Ville",  
"position" : {"lat" : 46.575851, "lon" : 6.539845}  
}  
}  
POST /test/offres/2  
{  
"title" : "offre 2",  
"locations" : [  
{  
"addresse" : "La Tuilière 18, 1163 Etoy",  
"position" : { "lat" : 46.476884, "lon" : 6.423888}  
},  
{  
"addresse" : "Rue de la Poste 9A, 1302 Vufflens-la-Ville",  
"position" : { "lat" : 46.577235, "lon" : 6.539905}  
}  
]  
}

GET /test/offres/\_search  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geo\_distance": {  
"distance": "34m",  
"locations.position": {  
"lat": 46.5769427,  
"lon": 6.539985799999999  
}  
}  
}  
}  
},  
"sort": {  
"\_geo\_distance": {  
"locations.position": {  
"lat": 46.5769427,  
"lon": 6.539985799999999  
},  
"order": "asc",  
"unit": "km"  
}  
},  
"size": 20  
}

--  
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/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 4, 2015, 11:03am UTC](https://discuss.elastic.co/t/search-document-with-multi-geo-point/22510/2 "2015-03-04T11:03:06Z")

</div>

If you search for localisations, index localisations.  
If you search for offers, index offers.

If you need to search for both, index both. In that case you might want to use parent/child but it comes with a cost.

If you want to use only nested docs, you need to filter on client.  
In 1.5.0, inner hits might help you: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-inner-hits.html#nested-inner-hits) [http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-inner-hits.html#nested-inner-hits](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-inner-hits.html#nested-inner-hits)

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 4 mars 2015 à 11:52, Jean Szabo [jean@netinfluence.ch](mailto:jean@netinfluence.ch) a écrit :
> 
> We have some offers with multiple adresse (geo\_point), and we wan't to search all adress around x km...
> 
> Actualy, we retrieve correct offers but with all geo\_point, and no just corresponding geo\_point.
> 
> Is it possible with nested object, without use parent/child ?
> 
> The other solution is to create a type localisations, with all adress and some offers informations and make our query in this type, is it the better solution ?
> 
> thanks
> 
> Jean
> 
> our tests :
> 
> DELETE /test/
> 
> POST /test/  
> {  
> "settings" : {  
> "number\_of\_shards" : 1  
> },  
> "mappings" : {  
> "offres" : {  
> "\_source" : { "enabled" : true },  
> "properties" : {  
> "title" : { "type" : "string" },  
> "locations" : {  
> "type" : "nested",  
> "include\_in\_parent": true,  
> "properties": {  
> "position": {  
> "type": "geo\_point",  
> "store": true  
> },  
> "addresse": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> POST /test/offres/1  
> {  
> "title" : "offre 1",  
> "locations" : {  
> "addresse" : "Grand-Rue 33, 1302 Vufflens-la-Ville",  
> "position" : {"lat" : 46.575851, "lon" : 6.539845}  
> }  
> }  
> POST /test/offres/2  
> {  
> "title" : "offre 2",  
> "locations" : [  
> {  
> "addresse" : "La Tuilière 18, 1163 Etoy",  
> "position" : { "lat" : 46.476884, "lon" : 6.423888}  
> },  
> {  
> "addresse" : "Rue de la Poste 9A, 1302 Vufflens-la-Ville",  
> "position" : { "lat" : 46.577235, "lon" : 6.539905}  
> }  
> ]  
> }
> 
> GET /test/offres/\_search  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "geo\_distance": {  
> "distance": "34m",  
> "locations.position": {  
> "lat": 46.5769427,  
> "lon": 6.539985799999999  
> }  
> }  
> }  
> }  
> },  
> "sort": {  
> "\_geo\_distance": {  
> "locations.position": {  
> "lat": 46.5769427,  
> "lon": 6.539985799999999  
> },  
> "order": "asc",  
> "unit": "km"  
> }  
> },  
> "size": 20  
> }
> 
> --  
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/691c3635-f66a-49f5-bcc6-46714408dd40%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [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/CCD8E189-06FB-41AE-BC83-135100196535%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/CCD8E189-06FB-41AE-BC83-135100196535%40pilato.fr).  
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, 12:28am UTC](https://discuss.elastic.co/t/search-document-with-multi-geo-point/22510/3 "2017-07-06T00:28:38Z")

</div>


