Include-in-all and include-in-root

I am not clear on the usage of include-in-all and include-in-root. Could
someone please explain with some examples or point to some good references

--
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.

if you have an array of objects, eg:

{
followers: [{ user: 1, name "john"}, { user: 2, name: "mary" }
}

then these get indexed as something like this:

{
"followers.user": [1,2],
"followers.name": ["john", "mary"]
}

But those arrays are actually multi-value fields, which have no intrinsic
order. they're just "bags" of values. You lose the correlation between
"user" and "name".

If you set "followers" to be type "nested" instead, then each object is
indexed as a separate (but externally invisible) document, and so you
retain the correlation between user and name. And you have to use nested
queries/filters to access those values. They are not visible in the parent
doc.

Sometimes, eg for faceting, you want those values to be visible in the
parent. In this case, set include_in_parent to true. This will index each
nested doc as a separate doc AND index the values into the parent doc (as
per my example above).

if you have nested objects within nested objects, then the parent of the
nested>nested is not the top-level document. In this case, use
include_in_root instead.

clint

On 22 May 2013 10:23, Chetana ambha.career@gmail.com wrote:

I am not clear on the usage of include-in-all and include-in-root. Could
someone please explain with some examples or point to some good references

--
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.

Thanks for the explanation.

  1. By specify include_in_parent = true or include_in_parent =true, Will I
    able to use other querybuilders instead of nestedQuery and also, exclude
    the 'path' in nested or other queries
    2.I could also see one more include_in_all. What is the use of include_in_all
    ?

Thanks
On Thursday, May 23, 2013 3:46:19 PM UTC+5:30, Clinton Gormley wrote:

if you have an array of objects, eg:

{
followers: [{ user: 1, name "john"}, { user: 2, name: "mary" }
}

then these get indexed as something like this:

{
"followers.user": [1,2],
"followers.name": ["john", "mary"]
}

But those arrays are actually multi-value fields, which have no intrinsic
order. they're just "bags" of values. You lose the correlation between
"user" and "name".

If you set "followers" to be type "nested" instead, then each object is
indexed as a separate (but externally invisible) document, and so you
retain the correlation between user and name. And you have to use nested
queries/filters to access those values. They are not visible in the parent
doc.

Sometimes, eg for faceting, you want those values to be visible in the
parent. In this case, set include_in_parent to true. This will index each
nested doc as a separate doc AND index the values into the parent doc (as
per my example above).

if you have nested objects within nested objects, then the parent of the
nested>nested is not the top-level document. In this case, use
include_in_root instead.

clint

On 22 May 2013 10:23, Chetana <ambha....@gmail.com <javascript:>> wrote:

I am not clear on the usage of include-in-all and include-in-root. Could
someone please explain with some examples or point to some good references

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.

On 24 May 2013 09:38, Chetana ambha.career@gmail.com wrote:

Thanks for the explanation.

  1. By specify include_in_parent = true or include_in_parent =true, Will I
    able to use other querybuilders instead of nestedQuery and also, exclude
    the 'path' in nested or other queries

Yes. Of course the values in the parent/root doc won't be correlated, but
it would be as though you had indexed the nested objects as type "nested"
and as type "object".

2.I could also see one more include_in_all. What is the use of include_in_all
?

ie should the nested values be included in the _all field

clint

--
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.

Great explanation as always Clint.

Btw, I highly recommend stealing some of them and embedding them back into
the ES reference docs as examples :slight_smile:

Thanks again

On Thursday, 23 May 2013 06:16:19 UTC-4, Clinton Gormley wrote:

if you have an array of objects, eg:

{
followers: [{ user: 1, name "john"}, { user: 2, name: "mary" }
}

then these get indexed as something like this:

{
"followers.user": [1,2],
"followers.name": ["john", "mary"]
}

But those arrays are actually multi-value fields, which have no intrinsic
order. they're just "bags" of values. You lose the correlation between
"user" and "name".

If you set "followers" to be type "nested" instead, then each object is
indexed as a separate (but externally invisible) document, and so you
retain the correlation between user and name. And you have to use nested
queries/filters to access those values. They are not visible in the parent
doc.

Sometimes, eg for faceting, you want those values to be visible in the
parent. In this case, set include_in_parent to true. This will index each
nested doc as a separate doc AND index the values into the parent doc (as
per my example above).

if you have nested objects within nested objects, then the parent of the
nested>nested is not the top-level document. In this case, use
include_in_root instead.

clint

On 22 May 2013 10:23, Chetana <ambha....@gmail.com <javascript:>> wrote:

I am not clear on the usage of include-in-all and include-in-root. Could
someone please explain with some examples or point to some good references

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.