Geo_bounding_box against nested subdocument


(bants) #1

Hi all,

I have data that looks something like:

{ "unique_id" : "foo",

"data_type" : "bar",
"contents" : [

                 { "value" : "chris", "location" : { "lat" : 40.12, 

"lon" : -71.34 }},

                 { "value" : "john", "location" : { "lat" : 30.15, 

"lon" : -81.34 }}

                ] 

}

*Is it possible to use a geo_bounding_box to search against these
locations? *I have seen that ES supports searching against multi-locations
per documenthttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html#_multi_location_per_document which
should work well for this, but I can't find an example of searching against
documents in which the locations are squirrelled away in sub-documents
inside an array/list (as above).

I also saw this posthttp://stackoverflow.com/questions/13177276/searching-term-in-subdocuments-with-elasticsearchthat suggested a wildcard could be used in the field key, which I thought
might allow me to do a geo_bounding_box against *.location or something
similar.

I'm also aware that the fix might be to change my document structure, but
would like to explore whether it is possible before doing that.

A big point you might pick up on - I haven't tried this for myself yet. I'm
at the stage of working out whether ElasticSearch will do what I need it to
do, so before I embark on writing the code I was hoping someone could help
me out?

Thanks for the help.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey,

you can simply search for the field contents.location and if anyone of the
sub objects match, the whole document should be returned.

--Alex

On Wed, Nov 13, 2013 at 2:56 PM, bants rich.brantingham@me.com wrote:

Hi all,

I have data that looks something like:

{ "unique_id" : "foo",

"data_type" : "bar",
"contents" : [

                 { "value" : "chris", "location" : { "lat" : 40.12,

"lon" : -71.34 }},

                 { "value" : "john", "location" : { "lat" : 30.15,

"lon" : -81.34 }}

                ]

}

*Is it possible to use a geo_bounding_box to search against these
locations? *I have seen that ES supports searching against multi-locations
per documenthttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html#_multi_location_per_document which
should work well for this, but I can't find an example of searching against
documents in which the locations are squirrelled away in sub-documents
inside an array/list (as above).

I also saw this posthttp://stackoverflow.com/questions/13177276/searching-term-in-subdocuments-with-elasticsearchthat suggested a wildcard could be used in the field key, which I thought
might allow me to do a geo_bounding_box against *.location or something
similar.

I'm also aware that the fix might be to change my document structure, but
would like to explore whether it is possible before doing that.

A big point you might pick up on - I haven't tried this for myself yet.
I'm at the stage of working out whether ElasticSearch will do what I need
it to do, so before I embark on writing the code I was hoping someone could
help me out?

Thanks for the help.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(bants) #3

Great - I was hoping it'd be that simple!

Thanks Alex.

On 14 Nov 2013, at 11:22, Alexander Reelsen alr@spinscale.de wrote:

Hey,

you can simply search for the field contents.location and if anyone of the sub objects match, the whole document should be returned.

--Alex

On Wed, Nov 13, 2013 at 2:56 PM, bants rich.brantingham@me.com wrote:
Hi all,

I have data that looks something like:

{ "unique_id" : "foo",
"data_type" : "bar",
"contents" : [
{ "value" : "chris", "location" : { "lat" : 40.12, "lon" : -71.34 }},
{ "value" : "john", "location" : { "lat" : 30.15, "lon" : -81.34 }}
]
}

Is it possible to use a geo_bounding_box to search against these locations? I have seen that ES supports searching against multi-locations per document which should work well for this, but I can't find an example of searching against documents in which the locations are squirrelled away in sub-documents inside an array/list (as above).

I also saw this post that suggested a wildcard could be used in the field key, which I thought might allow me to do a geo_bounding_box against *.location or something similar.

I'm also aware that the fix might be to change my document structure, but would like to explore whether it is possible before doing that.

A big point you might pick up on - I haven't tried this for myself yet. I'm at the stage of working out whether ElasticSearch will do what I need it to do, so before I embark on writing the code I was hoping someone could help me out?

Thanks for the help.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/Vig9S1n8NL0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4