The date field types in Solr support the date math expressions.
Solr中的日期字段类型支持日期数学表达式。

The date math expression makes it easy to create times relative to fixed moments in time and includes the current time which can be represented using the special value of NOW.
日期数学表达式使创建相对于时间中固定时刻的时间变得容易,并且包括可以使用NOW的特殊值表示的当前时间。

Date math syntax 日期数学语法

The 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, to represents a point in time two months from now, use:
例如,要表示两个月后的时间点,可以使用:

NOW+2MONTHS

To represents a point in time one day ago, use:
要表示一天前的时间点,可以使用:

NOW-1DAY

A slash is used to indicate rounding. To represents the beginning of the current hour, use:
斜线用来表示取整。要表示当前小时的开始,可以使用:

NOW/HOUR

To represent a point in time six months and three days into the future and then rounds that time to the beginning of that day, use:
要表示未来六个月零三天的时间点,然后将该时间取整到当天的开始,可以使用:

NOW+6MONTHS+3DAYS/DAY

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

Solr 6 date math supports TODAY.
Solr 6 开始日期计算支持 TODAY。

文档更新时间: 2020-02-09 23:22   作者:凌云文档