简体   繁体   English

Solr vs Elasticsearch用于嵌套文档

[英]Solr vs Elasticsearch for nested documents

I have been using solr for my project but recently I encountered Elasticsearch which seems to be very promising. 我一直在为项目使用solr,但是最近我遇到了Elasticsearch,这似乎非常有前途。 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? Solr最近刚刚添加了子文档,但是它和Elasticsearch一样好吗? Could Elasticsearch perform query on both parent and children at once? Elasticsearch可以一次对父级和子级执行查询吗? Thanks 谢谢

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). 我最近一直在研究这个主题,据我了解,ElasticSearch使处理嵌套文档的工作变得轻松很多,尽管Solr也支持嵌套(但在查询中不太灵活)。

So the features of ElasticSearch are: 因此,ElasticSearch的功能是:

  • "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: 使用Solr,您将必须:

  • Modify your schema.xml by adding the _ root _ field 通过添加_ root _字段来修改schema.xml

  • 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 ) 修改您的数据集,以使父文档和子文档具有特定的区分字段,尤其是childDocuments以指示子文档(有关此问题,请参阅)

  • 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. 最终可以将Solr的最新版本(5.1或更高版本)配置为支持嵌套(包括您必须更改输入数据结构),但是文档并不十分清楚,并且Internet上没有太多信息,因为这些功能是最新的。

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. 最重要的是,就嵌套文档而言,ElasticSearch可以完成Solr可以做的所有事情,并且可以用更少的精力和更流畅的学习曲线来做更多的事情。 So going with ElasticSearch seems more reasonable in this case. 因此,在这种情况下,使用ElasticSearch似乎更合理。

I am not aware of Elastic Search, so this is always 50% answer. 我不了解Elastic Search,所以这始终是50%的答案。 Solr works best with denormalized data. Solr最适合非规范化数据。 However, given that you have nested documents, you can use solr in two scenarios: 但是,鉴于您已经嵌套了文档,则可以在两种情况下使用solr:

  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. 即使您处理嵌套级别,solr在内部将它们作为非规范化管理。 I mean, when a parent have 2 children, you end up with three high level documents in solr. 我的意思是,当一个父母有2个孩子时,您最终会在Solr中获得三个高级文档。 And solr manages the relation part. 与solr管理关系部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM