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: 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 @dadoonet <https://twitter.com/dadoonet> | @elasticsearchfr <https://twitter.com/elasticsearchfr> | @scrutmydocs <https://twitter.com/scrutmydocs> > Le 4 mars 2015 à 11:52, Jean Szabo <[email protected]> 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 [email protected] > <mailto:[email protected]>. > 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?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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CCD8E189-06FB-41AE-BC83-135100196535%40pilato.fr. For more options, visit https://groups.google.com/d/optout.
