2016-05-10 23 views
2

使用Solr 6.0.0,我按照this walkthrough來配置集合中文檔的自動失效。Solr集合中文檔的自動失效

  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不同嗎?還是我錯過了明顯的東西?

回答

0

我只有一個默認的updateRequestProcessorChain,但是當我開始使用data_driven_schema_configs configset,並修改它以包含我的新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用戶名單。