【问题标题】:SOLR index on pdate field included in search results搜索结果中包含的更新字段上的 SOLR 索引
【发布时间】:2019-12-13 05:13:40
【问题描述】:

我正在从 SOLR 4.10.2 迁移到 8.1.1。出于某种原因,在 8.1.1 核心中,名为 IDX_ExpirationDate 的更新索引作为字段出现在搜索结果文档中。

我定义了其他几个索引并且(正确地)没有出现在结果中。但是我遇到问题的索引是唯一一个基于更新的索引。

这是一个演示该问题的示例 8.1.1 响应:

"response":{"numFound":58871,"start":0,"docs":[
      {
        "id":"11111",
        "ExpirationDate":"2018-01-26T00:00:00Z",
        "_version_":1641033044033798170,
        "IDX_ExpirationDate":["2018-01-26T00:00:00Z"]},
      {
        "id":"22222",
        "ExpirationDate":"2018-02-20T00:00:00Z",
        "_version_":1641032965380112384,
        "IDX_ExpirationDate":["2018-02-20T00:00:00Z"]},

ExpirationDate 应该存在,但 IDX_ExpirationDate 不应该存在。我知道我可能可以继续使用 date,但它已被弃用,升级到 8.1.1 的部分原因是使用最新的未弃用的东西 ;-)

我有一个名为 IDX_ExpirationDate 的索引,它基于一个名为 ExpirationDate 的字段,该字段是 4.10.2 中的一个日期字段:

<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
<field name="IDX_ExpirationDate" type="date" indexed="true" stored="false" multiValued="true" />
<field name="ExpirationDate" type = "date" indexed = "true" stored = "true" />
<copyField source="ExpirationDate" dest="IDX_ExpirationDate"/>

在 8.1.1 内核中,我将其配置为更新日期:

<fieldType name="pdate" class="solr.DatePointField" docValues="true"/>
<field name="IDX_ExpirationDate" type="pdate" indexed="true" stored="false" multiValued="true" />    
<field name="ExpirationDate" type = "pdate" indexed = "true" stored = "true" />
<copyField source="ExpirationDate" dest="IDX_ExpirationDate"/>

【问题讨论】:

    标签: apache solr lucene


    【解决方案1】:

    固定。

    根据 solruser 邮件列表上的 Shawn Heisey 的说法,pdate 类型默认为 docValues=true 和 useDocValuesAsStored="true",这使得它出现在结果中。

    所以我通过添加 useDocValuesAsStored="false" 更改了 IDX_ExpirationDate,重新加载了索引,它不再出现在结果中:

    <field name="IDX_ExpirationDate" type="pdate" indexed="true" stored="false" multiValued="true" useDocValuesAsStored="false"/>    
    

    【讨论】:

      猜你喜欢
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-09
      相关资源
      最近更新 更多