Nested Query vs. Has Child Query

Hi,

What exactly is the difference between a Nested Query and a Has Child
Query? Is the main difference around the indexing and updating (all docs
in case of nested docs and individual docs in case or parent-child docs)?

When is the former better or more appropriate than the latter?

Is there inherent (search) performance difference?

Thanks,
Otis

ELASTICSEARCH Performance Monitoring - http://sematext.com/spm/index.html

--

1 Like

Hi Otis,

the last time I was looking at this the advantage of Nested Documents is
better performance but less flexibility as opposed to Parent/Child
documents.

The performance of Nested Documents is driven by Lucene level
implementation. Check
http://lucene.apache.org/core/3_6_1/api/all/org/apache/lucene/search/join/ToParentBlockJoinQuery.htmlfor
more details.

The downside is that any update in parent or child documents means
reindexing of whole block.

Lukas

On Fri, Jan 11, 2013 at 12:34 AM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

Hi,

What exactly is the difference between a Nested Query and a Has Child
Query? Is the main difference around the indexing and updating (all docs
in case of nested docs and individual docs in case or parent-child docs)?

When is the former better or more appropriate than the latter?

Is there inherent (search) performance difference?

Thanks,
Otis

ELASTICSEARCH Performance Monitoring - Sematext Monitoring | Infrastructure Monitoring Service

--

--

Hi Lukáš,
("I put diacritics back in your name" ;))

Ah, I see, ES uses Lucene's BlockJoinQuery for Nested Query, of course!
Thanks for the pointer.

Good explanation of what happens under the hood:

Otis

ELASTICSEARCH Performance Monitoring - Sematext Monitoring | Infrastructure Monitoring Service

On Friday, January 11, 2013 6:32:36 AM UTC-5, Lukáš Vlček wrote:

Hi Otis,

the last time I was looking at this the advantage of Nested Documents is
better performance but less flexibility as opposed to Parent/Child
documents.

The performance of Nested Documents is driven by Lucene level
implementation. Check
http://lucene.apache.org/core/3_6_1/api/all/org/apache/lucene/search/join/ToParentBlockJoinQuery.htmlfor more details.

The downside is that any update in parent or child documents means
reindexing of whole block.

Lukas

On Fri, Jan 11, 2013 at 12:34 AM, Otis Gospodnetic <otis.gos...@gmail.com<javascript:>

wrote:

Hi,

What exactly is the difference between a Nested Query and a Has Child
Query? Is the main difference around the indexing and updating (all docs
in case of nested docs and individual docs in case or parent-child docs)?

When is the former better or more appropriate than the latter?

Is there inherent (search) performance difference?

Thanks,
Otis

ELASTICSEARCH Performance Monitoring - Sematext Monitoring | Infrastructure Monitoring Service

--

--