在 Amazon CloudSearch 中搜索时间范围

Search for Time Ranges in Amazon CloudSearch

(如果您想要 tl:dr,请向下滚动到粗体部分;)

我有一个简单的业务需求 - 在 Amazon CloudSearch 中搜索时间范围。因此,例如,我有一个带有“eventTime: 5:00” pm 的云搜索条目。问题是我只需要时间。根据 AWS docs on the date field:

date—contains a timestamp. Dates and times are specified in UTC (Coordinated Universal Time) according to IETF RFC3339: yyyy-mm-ddTHH:mm:ss.SSSZ. In UTC, for example, 5:00 PM August 23, 1970 is: 1970-08-23T17:00:00Z. Note that you can also specify fractional seconds when specifying times in UTC. For example, 1967-01-31T23:20:50.650Z.

此外,搜索日期范围this

To search for a range of dates (or times) in a date field, you use the same bracketed range syntax that you use for numeric values, but you must enclose the date string in single quotes. For example, the following request searches the movie data for all movies with a release date of January 1, 2013 or later:

You can use structured queries to search a field for a range of values. To specify a range of values, use a comma (,) to separate the upper and lower bounds and enclose the range using brackets or braces. A square brace, [ or ], indicates that the bound is included in the range, a curly brace, { or }, excludes the bound.

For example, to search the sample data set for movies released from 2008 to 2010 (inclusive), specify the range as [2008,2010].

To specify an open-ended range, omit the bound. For example, year:[2002,} matches all movies released from 2002 onward, and year:{,1970] matches all movies released through 1970. When you omit a bound, you must use a curly brace.

In a compound query, you use the range operator syntax to search for a range of values; for example: (range field=year [1967,}).

一切都很好,但我希望能够仅按时间搜索,例如任何一天上午 10 点到下午 6 点之间的所有约会。如何忽略日期组件?

没有直接支持,但一个简单的解决方法是添加一个仅包含数据时间部分的附加日期字段。

也就是说,yyyy-mm-dd 部分将始终不变,比如 1970-01-01,但您将为每个文档设置 HH:mm:ss.SSS。听起来您正在使用 javascript,所以 extract time from datetime using javascript 可能会对您有所帮助