0

(Scroll down to bolded section if you want the tl:dr;)

I have a simple business requirement - search for time ranges in Amazon CloudSearch. So, for example, I have a cloud search entry with `eventTime: 5:00' pm. The problem is that I only need the time. As per 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.

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:

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].

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,}).

This is all well and good, but I want to be able to search only by time, e.g. all appointments between 10am and 6pm on any day. How do I ignore the date component?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
VSO
  • 11,546
  • 25
  • 99
  • 187

1 Answers1

1

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. It sounds like you're using javascript so extract time from datetime using javascript may help you

alexroussos
  • 2,671
  • 1
  • 25
  • 38
  • Thanks for the answer, but I am not sure that I am fully following. My solution is to just have the same date for all entries with different times and disregard the time portion. That's what you are recommending as well, right? – VSO Jul 27 '17 at 02:19
  • Yes, assuming you meant "disregard the _date_ portion" – alexroussos Jul 27 '17 at 02:20
  • I did. I will keep this open until tomorrow to see if we are missing something, but looks like we came up with the only solution possible atm. Thanks again, will accept tomorrow morning. – VSO Jul 27 '17 at 02:22