【发布时间】:2017-10-05 11:02:15
【问题描述】:
我正在使用 Apache Solr 7 并尝试自动删除文档。我已经按照 Lucene 的文档完成了以下步骤。
步骤 1. 在 solrschema.xml 中
<updateRequestProcessorChain default="true">
<processor class="solr.processor.DocExpirationUpdateProcessorFactory">
<int name="autoDeletePeriodSeconds">30</int>
<str name="ttlFieldName">time_to_live_s</str>
<str name="expirationFieldName">expire_at_dt</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
步骤 2. 在 managed-schema.xml 中
<field name="id" type="string" indexed="true" stored="true" multiValued="false" />
<field name="time_to_live_s" type="string" stored="true" multiValued="false" />
<field name="expire_at_dt" type="date" stored="true" multiValued="false" />
第 3 步。我创建了一个名为 sample1 的核心并添加以下文档
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/sample1/update?commit=true' -d '[{ "id":"sample_doc_1","expire_at_dt":"NOW+10SECONDS"}]'
10 秒后,文档仍然存在。我错过了任何一步,还是我做错了什么?
【问题讨论】:
-
首先 -
autoDeletePeriodSeconds值告诉 Solr 它应该多久删除一次过期的文档,因此在这种情况下,文档最多可以存在 40 秒。expire_at_dt也应该只是+10SECONDS(而不是 NOW+...)。您是否在expire_at_dt字段中获得任何值? -
先生,如果我只添加
+10SECONDS,它会给出错误Invalid date string: +10SECONDS。另外,我得到2017-10-05T16:46:22.049Zforexpire_at_dt字段@MatsLindh