gpt4 book ai didi

javascript - 在 Amazon CloudSearch 中搜索时间范围

转载 作者:行者123 更新时间:2023-12-03 03:47:19 28 4
gpt4 key购买 nike

(如果您想要 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可能对你有帮助

关于javascript - 在 Amazon CloudSearch 中搜索时间范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45330123/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com