Hi,

I have some question regarding nested document queries.

For example, let’s say that I have many books, one of which is the following one:
Book _title: Nested documents for dummies
Chapter1_Title: Introduction
Chapter1_Content: Nested documents are fun.
Chapter2_Title: Which technology should I use?
Chapter2_Content: Lucene of course!

First I want to find books that contain an introduction and that are about Lucene. So I decide to flatten my data and use 3 multivalued fields (Book_Title,Chapter_Title and Chapter_Content), I index my document and then I get what I want when I run the following query : “ chapter_title:Introduction AND chapter_title:Lucene “ But now I want to find books that contain “fun” in a chapter which name is “introduction”. My model is no more valid (Chapter2_content is no more linked with Chapter2_title). That is why I change my datamodel and use nested documents: I now have a parent with a single valued field Book_title and different childs with single valued fields Chapter_title and Chapter_Content. Now, when I run the query “chapter_title: Introduction AND chapter_content:fun” I also get what I want… But what do I have to do if I want to use these two kinds of query with a unique data model? Maybe the only way to do this is to use nested documents and to index data both in child documents and in a flattened form in the parent document. Then we will be able to run the two different queries.

Do you have any other (better) idea?

Thank you,

Regards,

Aurélien

Reply via email to