Here is an example of a date math string used to query documents based on a time range
以下是用于根据时间范围查询文档的日期数学字符串的示例
timestamp:[2016-07-15T02:44:33.764Z TO 2016-07-15T02:44:33.800Z]
I also see usages of NOW like [* TO NOW], where is all the available strings documented? Also, is Date Math a type of formatting that is recognized by certain Date field types?
我也看到现在的用法,如[*现在],所有可用的字符串记录在哪里?此外,Date Math是某种日期字段类型可识别的格式吗?
1 个解决方案
#1
0
Working with dates: Solr only supports ISO-8601 formatted dates and timestamps:
使用日期:Solr仅支持ISO-8601格式的日期和时间戳:
The format used is a restricted form of the canonical representation of dateTime in the XML Schema specification – a restricted subset of ISO-8601. For those familiar with Java 8, Solr uses DateTimeFormatter.ISO_INSTANT for formatting, and parsing too with "leniency".
使用的格式是XML Schema规范中dateTime的规范表示的受限形式 - ISO-8601的受限子集。对于熟悉Java 8的人,Solr使用DateTimeFormatter.ISO_INSTANT进行格式化,并使用“leniency”进行解析。
YYYY-MM-DDThh:mm:ssZ
NOW is a special value as it's evaluated to the current timestamp, in general - it's bad for caching and might not be required (i.e. if you're querying a busy index, you might want to use a value rounded up or down instead).
NOW是一个特殊值,因为它被评估为当前时间戳,一般来说 - 它对于缓存很糟糕而且可能不需要(例如,如果您查询繁忙的索引,则可能需要使用向上或向下舍入的值)。
All timestamps can be modified using the Date Math syntax supported, where you can round a value to a specific unit or add / subtract units as required:
可以使用支持的日期数学语法修改所有时间戳,您可以在其中将值舍入到特定单位或根据需要添加/减去单位:
For example: this represents a point in time two months from now:
例如:这表示从现在起两个月后的某个时间点:
NOW+2MONTHS
This is one day ago:
这是一天前:
NOW-1DAY
A slash is used to indicate rounding. This represents the beginning of the current hour:
斜杠用于表示舍入。这代表当前时间的开始:
NOW/HOUR
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
#1
0
Working with dates: Solr only supports ISO-8601 formatted dates and timestamps:
使用日期:Solr仅支持ISO-8601格式的日期和时间戳:
The format used is a restricted form of the canonical representation of dateTime in the XML Schema specification – a restricted subset of ISO-8601. For those familiar with Java 8, Solr uses DateTimeFormatter.ISO_INSTANT for formatting, and parsing too with "leniency".
使用的格式是XML Schema规范中dateTime的规范表示的受限形式 - ISO-8601的受限子集。对于熟悉Java 8的人,Solr使用DateTimeFormatter.ISO_INSTANT进行格式化,并使用“leniency”进行解析。
YYYY-MM-DDThh:mm:ssZ
NOW is a special value as it's evaluated to the current timestamp, in general - it's bad for caching and might not be required (i.e. if you're querying a busy index, you might want to use a value rounded up or down instead).
NOW是一个特殊值,因为它被评估为当前时间戳,一般来说 - 它对于缓存很糟糕而且可能不需要(例如,如果您查询繁忙的索引,则可能需要使用向上或向下舍入的值)。
All timestamps can be modified using the Date Math syntax supported, where you can round a value to a specific unit or add / subtract units as required:
可以使用支持的日期数学语法修改所有时间戳,您可以在其中将值舍入到特定单位或根据需要添加/减去单位:
For example: this represents a point in time two months from now:
例如:这表示从现在起两个月后的某个时间点:
NOW+2MONTHS
This is one day ago:
这是一天前:
NOW-1DAY
A slash is used to indicate rounding. This represents the beginning of the current hour:
斜杠用于表示舍入。这代表当前时间的开始:
NOW/HOUR
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