Solr8.0.0日期搜索问题

时间:2019-04-18 02:39:36

标签: solr

在“日期”字段date_upload中搜索时遇到问题

我的架构文件在DATE字段中具有以下条目

<field name="date_upload" type="pdate" indexed="true" stored="true"/>

我的data-config.xml具有以下条目-

<dataConfig>
<dataSource type="JdbcDataSource"
            driver="com.mysql.jdbc.Driver"
            batchSize="-1"
            autoReconnect="true"
            socketTimeout="0"
            connectTimeout="0"
            encoding="UTF-8"
            url="jdbc:mysql://xxx.xxx.xxx.xx:3306/news?zeroDateTimeBehavior=convertToNull"
            user="admin"
            password="admin"/>
<document>
<!--<entity name="news10" query="select * from news10"
            deltaQuery="select posting_id from item where last_modified > '${dataimporter.last_index_time}'"> 
</entity>-->
<entity name="news10" pk="posting_id"
  query="SELECT * FROM news10"
  deltaImportQuery="SELECT * FROM news10
    WHERE posting_id = '${dataimporter.delta.posting_id}'"
  deltaQuery="SELECT posting_id FROM news10
    WHERE last_modified > '${dataimporter.last_index_time}'">
</entity>
</document>
</dataConfig>

以下内容无效-
fq = date_upload:现在(不起作用)
http://localhost:8983/solr/Nlive/select?fq=date_c%3ANOW&q= %3A

fq = date_upload:NOW-1DAY (不起作用)
fq = date_upload:(NOW-30DAYS)(不起作用)

fq = date_upload:[2018-12-01T:00:00:00Z至2019-04-17T00:00:00Z] (不起作用)

"msg":"Invalid Date in Date Math String:'2018-12-01T:00:00:00Z'",

fq = date_upload:[2018-12-01 TO 2019-04-17]给出以下错误

{
  "responseHeader":{
    "status":400,
    "QTime":1,
    "params":{
      "q":"*:*",
      "fq":"date_upload:[2018-12-01 TO 2019-04-17]",
      "_":"1555386354522"}},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"Invalid Date String:'2018-12-01'",
    "code":400}}

但是这些确实能带来结果-
fq = date_upload:[*到现在]
http://localhost:8983/solr/Nlive/select??fq=date_c%3A%5B %20TO%20NOW%5D&q = %3A *

1 个答案:

答案 0 :(得分:0)

该错误试图告诉您2018-12-01T:00:00:00Z是无效的时间戳-确实是。还有一个:应该存在:

2018-12-01T:00:00:00Z
           ^

使用正确的格式,2018-12-01T00:00:00Z应该可以按您期望的方式工作(这是范围的结尾)。

对于其他示例,fq=date_upload:NOW-1DAY说:“给我任何文件,其中datetimestamp恰好是一天前的毫秒”。那可能不会给您任何文件。在这些情况下,您还需要使用范围,例如[NOW-1DAY TO *]

相关问题