Freigeben über


Date and time in FAST Search Server queries and results - part 2

I discussed some locale aspects of date/time queries in a previous post, and was asked about how to specify date/time property filters in queries.

FAST Query Syntax (FQL)

You must specify datetime property restrictions using an explicit range in UTC timezone and syntax.

and(string("test", mode="or"),        write:range(min, 2011-06-09))

and(string("test", mode="or"), write:range(min, 2011-06-09, to="lt"))

 and(string("test", mode="or"), write:range(min, 2011-06-09T00:00:00Z))

Items updated before, but not including, June 09, 2011, 00:00:00 UTC. If you leave out the time component, it defaults to 00:00:00.
and(string("test", mode="or"), write:range(min, 2011-06-09, to="le")) Items updated before, and including, June 09, 2011, 00:00:00 UTC.

and(string("test", mode="or"), write:2011-06-09))

and(string("test", mode="or"), write:range(2011-06-09T00:00:00Z, 2011-06-10T00:00:00Z))

Items updated between (including) June 09, 2011, 00:00:00 UTC and (not including) June 10, 2011, 00:00:00 UTC.

Note that the first syntax expression is a special case, where the expression means the full day of 2011-06-09. This is a shortcut for the full range. For all explicit range expressions the datetime is interpreted as an exact date/time (down to the second), even if omitting the time component.

and(string("test", mode="or"), write:2011-06-09T13:45:00Z)) Items updated June 09, 2011, 13:45:00 UTC

 

Keyword Query Syntax

For Keyword Syntax, the date expression must be specified according to your locale and timezone. This is an important difference from FQL!

You can specify explicit dates, and use property operators (:, = <, <=, etc.). The query examples below search for items containing the word 'test' (using a Norwegian locale):

test write:"2011-06-09"test write="2011-06-09"test write='2011-06-09' Items updated June 09, 2011
test write="2011-06-09 11:45:00"

Items updated June 09, 2011.

Specifying a time component is allowed, but the time component is discarded (you can only restrict the query by full days).

test write>="2011-06-09" Items updated June 09, 201,1 or later
test write<"2011-06-09" Items updated before June 09, 2011

 

You can also use these handy shortcuts:

test write:"yesterday" test write="yesterday"

The time from the beginning of the day until the end of the day that precedes the current day.

test write:"this week"

The time from the beginning of the current week until the end of the current week. The week begins on monday.

test write:"this month"

The entire month that includes the current date.

test write:"last month"

The latest entire month that precedes the current month.

test write:"this year"

The entire year that includes the current date.

test write:"last year"

The latest entire year that precedes the current year.

 

Additional information:

Comments

  • Anonymous
    June 14, 2011
    For the example: and(string("test", mode="or"), write:range(2011-06-09T00:00:00Z, 2011-06-09T00:00:00Z)) I guess it should read 2011-06-10T00:00:00Z on the last parameter?

  • Anonymous
    June 14, 2011
    Yes, thanks.

  • Anonymous
    September 08, 2011
    Hi. Great post, thanks! I take it that and(string("test", mode="or"),       write:range(2011-06-09, max)) would bring me the documents updated since 2011-06-09? Cheers!

  • Anonymous
    November 27, 2011
    Hi Knut, This is very valuable.  I've never seen the "yesterday", "this week", etc. documented anywhere.  Do you know if official documentation exists on that? Thanks!

  • Anonymous
    February 26, 2015

  1. for range(min,2011-06-01), what will be the minimum value of date that range operator will take?
  2. for range(2011-06-01,max), what will be the maximum value of date that range operator will take? Any thoughts on this?