gpt4 book ai didi

集合中文档的Solr自动过期

转载 作者:行者123 更新时间:2023-12-05 07:49:38 27 4
gpt4 key购买 nike

使用 Solr 6.0.0,我遵循了 this walkthrough用于配置集合中文档的自动过期。

  1. 我的默认 solrconfig.xml 只有添加项(根据演练建议)

    <!-- auto delete collection -->
    <updateRequestProcessorChain default="true">
    <processor class="solr.TimestampUpdateProcessorFactory">
    <str name="fieldName">timestamp_dt</str>
    </processor>
    <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.FirstFieldValueUpdateProcessorFactory">
    <str name="fieldName">expire_at_dt</str>
    </processor>
    <processor class="solr.LogUpdateProcessorFactory" />
    <processor class="solr.RunUpdateProcessorFactory" />

  2. 我使用上述配置创建了集合;

    bin/solr create -c tweets -d tweets_configs -s 1 -rf 1
  3. 插入文档

    date -u && curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/tweets/update?commit=true' -d '[{"id":"live_forever"},{"id":"live_2_minutes_a", "time_to_live_s":"+120SECONDS"}]'

    date -u && curl -X POST -H 'Content-Type: application/json'    
    'http://localhost:8983/solr/tweets/update?commit=true&_ttl_=%2B5MINUTES' -d
    '[{"id":"live_a_long_time",
    "expire_at_dt":"3000-01-01T00:00:00Z" },
    {"id":"live_2_minutes_b",
    "time_to_live_s":"+120SECONDS"},
    {"id":"use_default_ttl"}]'
  4. 但是当我查询文档时,没有根据演练设置的过期时间;

    {
    "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":19,
    "params":{
    "q":"*:*",
    "indent":"on",
    "wt":"json"}},
    "response":{"numFound":5,"start":0,"docs":[
    {
    "id":"live_forever",
    "_version_":1533920832055672832},
    {
    "id":"live_2_minutes_a",
    "time_to_live_s":"+120SECONDS",
    "_version_":1533920832086081536},
    {
    "id":"live_a_long_time",
    "expire_at_dt":"3000-01-01T00:00:00Z",
    "_version_":1533921242796523520},
    {
    "id":"live_2_minutes_b",
    "time_to_live_s":"+120SECONDS",
    "_version_":1533921242825883648},
    {
    "id":"use_default_ttl",
    "_version_":1533921242829029376}]
    }}

而我希望看到根据步骤 1 中配置的多种机制自动设置到期时间。

它在 6.0.0 和 4.8 中的工作方式是否不同?还是我遗漏了一些明显的东西?

最佳答案

我只有一个默认的 updateRequestProcessorChain,但当我开始使用 data_driven_schema_configs 配置集并修改它以包含我的新 updateRequestProcessorChain 时,它没有被使用,因为我有;

<initParams path="/update/**">
<lst name="defaults">
<str name="update.chain">add-unknown-fields-to-the-schema</str>
</lst>
</initParams>

强制使用“add-unknown-fields-to-the-schema”updateRequestProcessorChain。

我不得不对此发表评论并使用所需的处理器更新我的默认值以使自动到期有效。确实非常强大的功能!

归功于 Chris Hostetter用于在 solr-user 列表上回答。

关于集合中文档的Solr自动过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37131117/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com