Solr根据发布的开始日期和结束日期获取文档
问题描述:
如何根据发布日期范围查询所有已发布的文档。我的索引中有以下日期时间字段。Solr根据发布的开始日期和结束日期获取文档
<field name="title" type="string" indexed="true" termOffsets="true" stored="true" termPositions="true" termVectors="true" multiValued="false"/>
<field name="publishStart" type="date" indexed="true" stored="true" multiValued="false"/>
<field name="publishEnd" type="date" indexed="true" stored="true" multiValued="false"/>
我想要实现这样的SQL查询条件语句:
(publishStart <= now() AND publishStart is not null) AND (publishEnd >= now() OR publishEnd is null)
例如
查询应符合下列文件:
现在让()= 2016-06-14T08:00:00Z
title: Article 1
publishStart: 2016-06-14T07:00:00Z
title: Article 2
publishStart: 2016-06-14T07:00:00Z
publishEnd: 2016-06-15T07:00:00Z
:)谢谢
答
查询你要找因为是
publishStart:[* TO NOW] AND (-publishEnd:[* TO NOW] AND publishEnd:[* TO *])
请注意,Solr没有简单的方法来指定您需要空值s,所以在查询的第二部分,我们得到所有结果并排除我们不需要的东西。 Here是一个有关这个问题的有趣的文章。
谢谢:)... – Awesemo