当索引包含数百万个文档时在 Solr 中分面

Faceting in Solr when index contains millions of documents

我正在开发一个项目,该项目使用包含几百万个文档的 solr 索引,我们最近遇到了内存问题。 Faceting 在我们的几个字段上变得不可用——solr 用完了堆内存——因为包含这些字段的文档数量太多。

除了增加内存,我们还有什么选择?我们将内存增加视为一种临时解决方案,因为文档数量每天增加几十万个文档。

我正在关注 solrcloud,但我不确定这是正确的解决方案。

有什么建议吗?

谢谢!

在solr之前你能想到的是solr多核

在单个实例上,Solr 有一个叫做 SolrCore 的东西,它本质上是一个单一的索引。如果你想要多个索引,你创建多个 SolrCores。

借助 SolrCloud,单个索引可以跨越多个 Solr 实例。

这意味着单个索引可以由不同机器上的多个 SolrCore 组成。

组成一个逻辑索引的这些SolrCore是一个集合。

集合本质上是一个跨越许多 SolrCore 的单一索引,既用于索引扩展又用于冗余。

如果您想将 2 个 SolrCore Solr 设置移动到 SolrCloud,您将有 2 个集合,每个集合由多个单独的 SolrCore 组成。

SolrCloud 在 Solr 中添加了分布式功能。 通过此启用,您可以拥有高可用性、容错的 Solr 服务器集群。

当您需要大规模、容错、分布式索引和搜索功能时,请使用 SolrCloud。

您可以在此处获取有关 SolrCloud 的更多信息

https://cwiki.apache.org/confluence/display/solr/SolrCloud

FacetFields: Allow for facet counts based on distinct values in a field. There are two methods for FacetFields, one that performs well with few distinct values in a field, and the other for when a field contains many distinct values (generally, thousands and up – you should test what works best for you).

The first method, facet.method=enum, works by issuing a FacetQuery for every unique value in the field. As mentioned, this is an excellent method when the number of distinct values in a field is small. It requires excessive memory though, and breaks down when the number of distinct values gets large. When using this method, be careful to ensure that your FilterCache is large enough to contain at least one filter for every distinct value you plan on faceting on.

The second method uses the Lucene FieldCache (future version of Solr will actually use a different non-inverted structure – the UnInvertedField). This method is actually slower and more memory intensive for fields with a low number of unique values, but if you have a lot of uniques, this is the way to go. This method uses the FieldCache to look up the values for the given field for each document, and every time a document with a given value is found, the value has its count incremented.

请检查为每个缓存分配的内存,以及您是否可以调整 FieldCache 来处理这种情况。 (正如您所提到的,type3type4 有大量文档。

以上信息的来源是Scaling Lucene and Solr. I found one more article which talks about solr faceting You are faceting it wrong