1

I have been using solr for my project but recently I encountered Elasticsearch which seems to be very promising. My project requires ability to handle nested documents and I would like to know which one does better job. Solr just added child documents recently but is it as good as Elasticsearch's? Could Elasticsearch perform query on both parent and children at once? Thanks

Yangrui
  • 1,217
  • 2
  • 17
  • 41

2 Answers2

4

I've been looking into the subject recently and to my understanding ElasticSearch makes the life a lot easier when working with nested documents, although Solr also supports nesting (but is less flexible in querying).

So the features of ElasticSearch are:

  • "Seamlessly" supports nesting: you don't have to change your nested documents structure or add specific fields. However, you need to indicate in the mapping what fields are nested when creating the index

  • Supports nested query with "nested" and "path":

  • Supports aggregation and filtering with nested docs: also via "nested" and "path".

With Solr you will have to:

  • Modify your schema.xml by adding the _ root _ field

  • Modify your dataset so that parent and child documents would have a specific distinguishing field, in particular, childDocuments to indicate children (see more at this question)

  • Aggregation and filtering on nested documents promises to be very complicated if not impossible.

Also, nested fields are not supported at all.

Recent Solr versions (5.1 and up) can eventually be configured to support nesting (including you'll have to change your input data structure), however, documentation is not very clear and there is not much information on the Internet because these features are recent.

The bottomline is that in the sense of nested documents ElasticSearch can do everything that Solr can and even more with less effort and smoother learning curve. So going with ElasticSearch seems more reasonable in this case.

Community
  • 1
  • 1
alisa
  • 1,336
  • 2
  • 15
  • 21
1

I am not aware of Elastic Search, so this is always 50% answer. Solr works best with denormalized data. However, given that you have nested documents, you can use solr in two scenarios:

  1. Query for parent, with a child attribute
  2. Query for all children of a parent.

You can use block join to perform the above queries. Even though, you deal with nested levels, solr internally manages them as denormalized. I mean, when a parent have 2 children, you end up with three high level documents in solr. And solr manages the relation part.

Ramzy
  • 6,948
  • 6
  • 18
  • 30
  • 1
    Thanks again. I've tried Elasticsearch and its accuracy was far behind Solr's. I am going to stick with Solr. – Yangrui Aug 09 '15 at 20:27