简体   繁体   English

Solr查询中的NOW / DAY如何工作?

[英]How does NOW/DAY in a Solr query work?

I am trying to figure out why Solr thinks an doc is in the past. 我试图弄清楚为什么Solr认为文档是过去的。 My query is set up to use 我的查询已设置为可以使用

published:[* TO NOW/DAY]

The doc I am hoping it will find has a published date of 我希望该文档的发布日期为

2012-04-30T04:00:00Z

Current Solr server time is Mon Apr 30 18:26:47 EDT 2012. My understanding says that the document should have been found by now, which makes me think the NOW/DAY doesn't work the way I think it does. Solr服务器的当前时间是2012年4月30日星期一,美国东部夏令时间。我的理解是,到现在为止应该已经找到该文档,这使我认为NOW / DAY不能按我认为的方式工作。 Does anybody know how the NOW/DAY evaluates dates and why when Solr is not finding my doc when I add that stipulation? 有谁知道NOW / DAY如何评估日期以及为什么当我添加该规定时Solr找不到我的文档?

NOW/DAY means take the actual date time and round it to the day (leaving out the time). NOW/DAY表示获取实际日期时间并将其四舍五入为一天(不包括时间)。 Of course if the actual date is 2012-04-30 , any hour, the result is 2012-04-30T00:00:00Z . 当然,如果实际日期为2012-04-30 ,则为任何小时,结果为2012-04-30T00:00:00Z

Try just using NOW. 立即尝试使用。 I suspect that NOW/DAY is equal to 2012-04-30T00:00:00Z. 我怀疑NOW / DAY等于2012-04-30T00:00:00Z。

NOW/DAY rounds down to midnight last night. NOW/DAY舍入到昨晚的午夜。 If you want the midnight of current day change with NOW+1DAY/DAY . 如果您想将当日的午夜更改为NOW+1DAY/DAY

Date Math Syntax 日期数学语法

Date math expressions consist either adding some quantity of time in a specified unit, or rounding the current time by a specified unit. 日期数学表达式包括以指定单位增加一定数量的时间,或以指定单位四舍五入当前时间。 expressions can be chained and are evaluated left to right. 表达式可以链接起来,并从左到右求值。

For example: this represents a point in time two months from now: 例如:这表示从现在起两个月的时间点:

NOW+2MONTHS NOW + 2个月

This is one day ago: 这是一天前:

NOW-1DAY NOW-1DAY

A slash is used to indicate rounding. 斜线用于表示舍入。 This represents the beginning of the current hour: 这代表当前时间的开始:

NOW/HOUR NOW /小时

The following example computes (with millisecond precision) the point in time six months and three days into the future and then rounds that time to the beginning of that day: 以下示例计算(以毫秒为单位)未来六个月零三天的时间点,然后将该时间舍入到当天的开始:

NOW+6MONTHS+3DAYS/DAY NOW + 6个月+ 3DAYS / DAY

Note that while date math is most commonly used relative to NOW it can be applied to any fixed moment in time as well: 请注意,虽然日期数学相对于NOW最常用,但它也可以应用于任何固定的时间:

1972-05-20T17:33:18.772Z+6MONTHS+3DAYS/DAY 1972-05-20T17:33:18.772Z + 6个月+ 3DAYS / DAY

Quoted from Apache Solr Reference Guide - Working with Dates 引自《 Apache Solr参考指南-处理日期》

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM