Although I would agree that being able to detect it automatically could make things simpler, I think that the fact that it is excplicit is more flexible. For example, it can make sense to copy field values into the root document[1]. This can help speed-up some queries that don't need to know about the tree structure of your document. And in that case you have two ways to search the same field name: - either through the root document: faster but less flexible - or through the nested document: less flexible but slower
The fact that nested queries are explicit allows you to choose the way that you want the field to be queried. For aggregations, I think it is also nice to make it explicit so that counts are not surprising: imagine that you have a document with properties stored as nested documents and each property having a name. If you run a terms aggregation on the property name from the root document, buckets will count how many root documents have this property name. On the other hand, if you run this terms aggregation through a nested field, this will count the number of _properties_ that have this name. Since each document can have several properties, counts might be much higher. [1] http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html On Wed, May 21, 2014 at 9:55 PM, Jad <[email protected]> wrote: > Hi All, > > I've been thinking about why "nested" fields need to be handled with a > special "nested" query and aggregation type. Is it to handle the case where > there are multiple nested levels, to be able to control whether a query > involving two nested fields is within the same nested instance or across > two nested instances? > > Thanks > Jad. > > -- > 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/19b47173-41f2-4a5e-9bb8-efc84f0f9a56%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/19b47173-41f2-4a5e-9bb8-efc84f0f9a56%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Adrien Grand -- 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/CAL6Z4j60svm9864bHyz1Da0JU%3DLN3%3DtgOCoyPN06rN5Q0oE4NA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
