【问题标题】:Solr4.1 Cant delete documents older than 30 daysSolr4.1 无法删除超过 30 天的文档
【发布时间】:2013-02-27 23:53:24
【问题描述】:

我正在运行 Solr4.1。 我确实有一个 version 字段,但我不明白如何通过查询删除时间。我的架构中没有任何字段具有我可以看到的时间戳。

我要做的是运行一个查询,删除所有早于 30 天的文档。

我已经尝试了所有可以在网上找到的东西。

curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>_version_:[* TO NOW-60DAYS] </query></delete>'

curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>timestamp:[* TO NOW-60DAYS] </query></delete>'

curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>createTime:[* TO NOW-60DAYS] </query></delete>'

其他删除工作正常,例如

curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>field:value</query></delete>'

【问题讨论】:

    标签: solr


    【解决方案1】:

    您可以启用包含在 schema.xml 中的时间戳字段,只是将其注释掉。每次将文档插入索引时,该字段都会自动填充当前日期时间。在您的 schema.xml 中查找以下内容:

     <!-- Uncommenting the following will create a "timestamp" field using
          a default value of "NOW" to indicate when each document was indexed.
       -->
     <!--
     <field name="timestamp" type="date" indexed="true" stored="true" 
        default="NOW" multiValued="false"/>
     -->
    

    您需要重新索引您的文档以设置此值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 2018-08-24
      • 1970-01-01
      相关资源
      最近更新 更多