[英]auto delete of documents is not working in Apache Solr
我正在使用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秒后,文檔仍然存在。 我錯過了任何步驟嗎,還是我做錯了什么?
我認為在索引expire_at_dt
,您應該設置字段time_to_live_s
而不是expire_at_dt
,並且值+10SECONDS
或任何您想要的都可以。
作為參考:
ttlFieldName-此過程應在每個處理的文檔中查找的字段名稱,默認為ttl 。 如果文檔中存在指定的字段名稱,則文檔字段值將被解析為相對於NOW的日期數學表達式,並且將使用expirationFieldName將結果添加到文檔中。 用於禁用此功能。
如果要直接設置到期日期,則應設置正確的日期字符串,而不是日期數學表達式。
我在這里有自動刪除代碼的完整工作示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.