首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Solr使用ttl字段的默认值自动删除

Solr使用ttl字段的默认值自动删除
EN

Stack Overflow用户
提问于 2017-01-18 13:07:08
回答 1查看 1.4K关注 0票数 3

我正在尝试使用solr-6的Solr自动删除功能。我在我的managed-schema.xml和solrconfig.xml中做了以下更改。

托管架构

代码语言:javascript
复制
<!--expiration date field-->
<field name="eDate" type="date" multiValued="false" indexed="true" stored="true"/>
<field name="ttl" type="string" multiValued="false" indexed="true" stored="true" default="+90SECONDS"/>

solrconfig

代码语言:javascript
复制
<processor class="solr.processor.DocExpirationUpdateProcessorFactory">
    <int name="autoDeletePeriodSeconds">30</int>
    <str name="ttlFieldName">ttl</str>
    <str name="expirationFieldName">eDate</str>
</processor>

如果我在传入的文档中显式地设置了ttl字段,或者在更新请求中设置了ttl请求参数,我就能够像预期的那样使用自动删除功能。但是,如果我没有显式地设置ttl字段,我希望使用管理架构中指定的ttl的默认值。当我尝试这样做时,使用默认值生成了ttl字段,但没有生成相应的eDate字段。

有没有可能做我想做的事?如果是,那我该怎么做呢?如果您需要任何进一步的详细信息,请留下评论。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-18 15:18:32

我无法通过field描述中的default参数使其工作,但我通过添加solr.DefaultValueUpdateProcessorFactory使其工作

在我的更新链中,我有这个:

代码语言:javascript
复制
    <processor class="solr.DefaultValueUpdateProcessorFactory">
        <str name="fieldName">ttl</str>
        <str name="value">+15SECONDS</str>
    </processor>
    <processor class="solr.processor.DocExpirationUpdateProcessorFactory">
        <int name="autoDeletePeriodSeconds">5</int>
        <str name="ttlFieldName">ttl</str>
        <str name="expirationFieldName">eDate</str>
    </processor>

我更改了值以进行更快的测试:)指向工作code的链接

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41711740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档