Michael
Michael

Reputation: 1905

Google App Engine Search API, Searching DateField value before certain date

With Google App Engine, using Search API Documents and Index, where Documents have DateField named "updated", how it is possible to query for Documents updated before 2014-05-13T00:00:00Z ? I tried

query = 'updated < %s' % (mydate)

So the value is 'updated < 2014-05-13T17:21:35.499000' and it results in QueryError: Failed to parse query "updated < 2014-05-13T17:21:35.499000"

Something is wrong with my syntax, but I don't know of any reference to the syntax of search API queries. Whatever little I could understand looking at the source of c:\Program Files (x86)\Google\google_appengine\google\appengine\api\search\QueryLexer.py, seems comparisons are allowed. Any ideas?

Upvotes: 0

Views: 657

Answers (2)

Sampathkumar P
Sampathkumar P

Reputation: 15

approval_date here is actually an Atom field. Still it isn't working.

query = approval_date < olderTimeInISO8601

There must be another way to do it.

Upvotes: 0

Greg
Greg

Reputation: 10360

You can only filter using a date, not a datetime (see "Special treatment of string and date fields" here). As follows:

query = 'updated < %s' % mydate.date()

The query documentation is here.

Upvotes: 3

Related Questions