好吧,我正在编写一些方法来返回间隔日期范围内的solr文档。 文档以ISO 8601格式存储日期字段。
有什么想法吗?
THX
答案 0 :(得分:68)
在SOLR wiki中查看一些文档和示例:
时间戳:[*现在]
createdate:[1976-03-06T23:59:59.999Z TO *]
createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]
pubdate:[NOW-1YEAR / DAY TO NOW / DAY + 1DAY]
createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z + 1YEAR]
createdate:[1976-03-06T23:59:59.999Z / YEAR TO 1976-03-06T23:59:59.999Z]
希望这有帮助, 大卫。
答案 1 :(得分:32)
在这里,您可以找到有关范围查询的更多详细信息
https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser
一些例子
1. Exact Matching: q= modify_date:"2012-07-06T9:23:43Z"
2. Less than: q= modify_date:{* TO 2012-07-06T9:23:43Z }
3. More than: q= modify_date:{ 2012-07-06T9:23:43Z TO *}
4. Less or equal than: modify_date:[* TO 2012-07-06T9:23:43Z]
5. More or equal than: modify_date:[ 2012-07-06T9:23:43Z TO *]
方括号[]表示包含范围查询,该查询匹配包括上限和下限的值。
Curly bracket {}表示一个独占范围查询,它匹配上限和下限之间的值,但不包括上限和下限。
答案 2 :(得分:3)
假设Schema中的字段为Modified_Date,则可以应用以下范围查询:
Modified_Date:[2015-04-20T07:49:00Z TO *]
Modified_Date:[2015-04-20T07:49:00Z TO 2015-05-
20T07:33:00Z]
Modified_Date:[2015-04-20T07:49:00Z TO NOW]
Modified_Date:[NOW-7DAY/DAY TO NOW]
Modified_Date:"2015-05-27T10:04:00Z"
Modified_Date:NOW
Modified_Date:NOW/DAY
Modified_Date:NOW/HOUR
Modified_Date:NOW-1YEAR
Modified_Date:NOW-2YEARS
Modified_Date:NOW-3HOURS-30MINUTES
Modified_Date:"2008-07-04T13:45:04Z/DAY"
Modified_Date:[* TO NOW]
Modified_Date://DAY
Modified_Date://HOUR
Modified_Date:[ * 2015-04-20T07:49:00Z ]
Modified_Date:[2015-04-20T07:49:00Z *]