简体   繁体   English

在Amazon CloudSearch中搜索时间范围

[英]Search for Time Ranges in Amazon CloudSearch

(Scroll down to bolded section if you want the tl:dr;) (如果需要tl:dr,请向下滚动至粗体部分;)

I have a simple business requirement - search for time ranges in Amazon CloudSearch. 我有一个简单的业务需求-在Amazon CloudSearch中搜索时间范围。 So, for example, I have a cloud search entry with `eventTime: 5:00' pm. 因此,例如,我有一个带有`eventTime:5:00'pm的云搜索条目。 The problem is that I only need the time. 问题是我只需要时间。 As per AWS docs on the date field : 根据日期字段上的AWS文档

date—contains a timestamp. 日期-包含时间戳记。 Dates and times are specified in UTC (Coordinated Universal Time) according to IETF RFC3339: yyyy-mm-ddTHH:mm:ss.SSSZ. 日期和时间是根据IETF RFC3339在UTC(世界标准时间)中指定的:yyyy-mm-ddTHH:mm:ss.SSSZ。 In UTC, for example, 5:00 PM August 23, 1970 is: 1970-08-23T17:00:00Z. 例如,在UTC中,1970年8月23日下午5:00是:1970-08-23T17:00:00Z。 Note that you can also specify fractional seconds when specifying times in UTC. 请注意,在UTC中指定时间时,您也可以指定小数秒。 For example, 1967-01-31T23:20:50.650Z. 例如,1967-01-31T23:20:50.650Z。

Furthermore, there is this on searching date ranges: 此外,在搜索日期范围内还有以下内容:

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: 例如,以下请求在电影数据中搜索发布日期为2013年1月1日或更晚的所有电影:

and

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]. 例如,要搜索样本数据集以查找2008年至2010年(含)之间发行的电影,请将范围指定为[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. 例如,year:[2002,}匹配2002年以后发行的所有电影,year:{,1970]匹配1970年之前发行的所有电影。省略界限时,必须使用花括号。

In a compound query, you use the range operator syntax to search for a range of values; 在复合查询中,您使用范围运算符语法来搜索值的范围; for example: (range field=year [1967,}). 例如:(range field = year [1967,})。

This is all well and good, but I want to be able to search only by time, eg all appointments between 10am and 6pm on any day. 这一切都很好, 但是我希望只能按时间进行搜索,例如,每天的上午10点至下午6点之间的所有约会。 How do I ignore the date component ? 如何忽略日期部分

That isn't directly supported but a simple workaround is to add an additional date field that contains only the time portion of your data. 不直接支持该方法,但是一个简单的解决方法是添加一个仅包含数据时间部分的附加日期字段。

That is, the yyyy-mm-dd portion will always be constant, say 1970-01-01 but you will set the HH:mm:ss.SSS for each document. 也就是说, yyyy-mm-dd部分将始终保持不变,例如1970-01-01但是您将为每个文档设置HH:mm:ss.SSS It sounds like you're using javascript so extract time from datetime using javascript may help you 听起来您正在使用javascript,所以使用javascript 从datetime提取时间可能会对您有所帮助

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

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