如何在solr中使用docvalues

how to use docvalues in solr

我正在尝试将文档值放在一些我们经常用于排序的字段上。为了避免使用 fieldCache 而是使用磁盘上的文档值,我在 schema.xml

中使用了如下内容
<field indexed="true" multiValued="false" name="date" docValues="true" stored="true" omitNorms="true" omitPositions="true" termVectors="false" termPositions="false" termOffsets="false" type="TrieDateField"/>

我想知道在这个字段上排序时使用正向索引而不是 fieldCache 是否足够,或者我是否必须发送类似

的内容
q:date:[NOW/HOUR-1HOUR TO NOW/HOUR]&fieldCache:false

在每个查询中也同时对该字段进行排序。

我正在使用 Datastax 5.0

显然这应该足够了。根据 docValues:

上的官方 Solr 文档

To use docValues, you only need to enable it for a field that you will use it with.

另请关注:

If you have already indexed data into your Solr index, you will need to completely re-index your content after changing your field definitions in schema.xml in order to successfully use docValues.

顺便说一句,我还想确保您的 schema.xml 是 100% 清楚的:... type="TrieDateField"。我假设它应该是 ... type="date"date 是预定义的字段类型,实现了 solr.TrieDateField)。