2016-07-14 20 views
0

公開日の範囲からすべての公開文書を照会する方法を教えてください。私は私のインデックスで利用可能な以下の日時フィールドを持っています。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 

:)おかげ

あなたが探している

答えて

0

クエリforは

publishStart:[* TO NOW] AND (-publishEnd:[* TO NOW] AND publishEnd:[* TO *]) 

です.Solrには、空の値が必要であることを指定する簡単な方法がありませんしたがって、クエリの2番目の部分では、すべての結果が得られ、必要のないものは除外されます。 Hereはこの問題に関する興味深い記事です。

+0

ありがとう:)... – Awesemo

関連する問題