I've been try to use Elasticsearch to query heavily nested documents like
below (simplified document). In the document below, I would like to search
for all color values without having to specify a full "path" in nested
queries/filters. More like a wildcard path, for example color.*.value=v2 .
I could also include color types (blue, gray,red, etc) in the inner objects
and remove one level of nesting, but I need the nesting to update
(overwrite) a particular color type array (e.g. all blues). Including this
information in the inner object and decreasing nesting levels will
complicate updates.
If this is not possible, I would greatly appreciate it if I was pointed in
the right direction.
-Ash
You can set "include_in_root" to true on your nested objects and use
multi_match query with a wildcard:
{"multi_match":{"query":"v2","fields":["color.*.value"]}}. However, I would
recommend moving color into the nested object and complicating updates.
On Thursday, December 20, 2012 3:49:58 PM UTC-5, Ash wrote:
Hi,
I've been try to use Elasticsearch to query heavily nested documents like
below (simplified document). In the document below, I would like to search
for all color values without having to specify a full "path" in nested
queries/filters. More like a wildcard path, for example color.*.value=v2 .
I could also include color types (blue, gray,red, etc) in the inner
objects and remove one level of nesting, but I need the nesting to update
(overwrite) a particular color type array (e.g. all blues). Including this
information in the inner object and decreasing nesting levels will
complicate updates.
If this is not possible, I would greatly appreciate it if I was pointed
in the right direction.
-Ash
Multi_match will only work if I was matching a single field. From what I
understand this would completely omit the structure of the data and I won't
be able to issue nested queries. As an example, the following query should
not return any hits, but it's not.
On Thursday, 20 December 2012 14:02:16 UTC-8, Igor Motov wrote:
You can set "include_in_root" to true on your nested objects and use
multi_match query with a wildcard:
{"multi_match":{"query":"v2","fields":["color.*.value"]}}. However, I
would recommend moving color into the nested object and complicating
updates.
On Thursday, December 20, 2012 3:49:58 PM UTC-5, Ash wrote:
Hi,
I've been try to use Elasticsearch to query heavily nested documents like
below (simplified document). In the document below, I would like to search
for all color values without having to specify a full "path" in nested
queries/filters. More like a wildcard path, for example color.*.value=v2
.
I could also include color types (blue, gray,red, etc) in the inner
objects and remove one level of nesting, but I need the nesting to update
(overwrite) a particular color type array (e.g. all blues). Including this
information in the inner object and decreasing nesting levels will
complicate updates.
If this is not possible, I would greatly appreciate it if I was pointed
in the right direction.
-Ash
Exactly! That's why I recommended moving color into the nested object.
On Thursday, December 20, 2012 7:22:40 PM UTC-5, Ash wrote:
Thank you for your reply.
Multi_match will only work if I was matching a single field. From what I
understand this would completely omit the structure of the data and I won't
be able to issue nested queries. As an example, the following query should
not return any hits, but it's not.
On Thursday, 20 December 2012 14:02:16 UTC-8, Igor Motov wrote:
You can set "include_in_root" to true on your nested objects and use
multi_match query with a wildcard:
{"multi_match":{"query":"v2","fields":["color.*.value"]}}. However, I
would recommend moving color into the nested object and complicating
updates.
On Thursday, December 20, 2012 3:49:58 PM UTC-5, Ash wrote:
Hi,
I've been try to use Elasticsearch to query heavily nested documents
like below (simplified document). In the document below, I would like to
search for all color values without having to specify a full "path" in
nested queries/filters. More like a wildcard path, for example
color.*.value=v2 .
I could also include color types (blue, gray,red, etc) in the inner
objects and remove one level of nesting, but I need the nesting to update
(overwrite) a particular color type array (e.g. all blues). Including this
information in the inner object and decreasing nesting levels will
complicate updates.
If this is not possible, I would greatly appreciate it if I was pointed
in the right direction.
-Ash
On Thursday, 20 December 2012 16:29:16 UTC-8, Igor Motov wrote:
Exactly! That's why I recommended moving color into the nested object.
On Thursday, December 20, 2012 7:22:40 PM UTC-5, Ash wrote:
Thank you for your reply.
Multi_match will only work if I was matching a single field. From what I
understand this would completely omit the structure of the data and I won't
be able to issue nested queries. As an example, the following query should
not return any hits, but it's not.
On Thursday, 20 December 2012 14:02:16 UTC-8, Igor Motov wrote:
You can set "include_in_root" to true on your nested objects and use
multi_match query with a wildcard:
{"multi_match":{"query":"v2","fields":["color.*.value"]}}. However, I
would recommend moving color into the nested object and complicating
updates.
On Thursday, December 20, 2012 3:49:58 PM UTC-5, Ash wrote:
Hi,
I've been try to use Elasticsearch to query heavily nested documents
like below (simplified document). In the document below, I would like to
search for all color values without having to specify a full "path" in
nested queries/filters. More like a wildcard path, for example
color.*.value=v2 .
I could also include color types (blue, gray,red, etc) in the inner
objects and remove one level of nesting, but I need the nesting to update
(overwrite) a particular color type array (e.g. all blues). Including this
information in the inner object and decreasing nesting levels will
complicate updates.
If this is not possible, I would greatly appreciate it if I was
pointed in the right direction.
-Ash
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.