4

I'm wondering how to have a millisecond since epoch datetime field (e.g. 1362960734565) that I can search on easily (e.g. all documents created after 1234560123456), or do I need to implement some method to split up the date or put it in another format, as it won't work as a NUMBER or a DATE.

According to Google's documentation for the search API (https://developers.google.com/appengine/docs/java/search/overview#Describing_Data_with_Documents):

Document Fields

Each document contains fields that will contain a particular type of content. The content type is identified by a Field builder to set a field's content type as follows:

  • TEXT: plain text
  • HTML: HTML formatted text
  • ATOM: a string which is treated as a single token
  • NUMBER: a numeric value (either float or integer) between 2,147,483,647 and -2,147,483,647
  • DATE: a date with no time component
  • GEO_POINT: a locale based on latitude and longitude
Numbat
  • 379
  • 2
  • 15

1 Answers1

5

My current solution:

With the timestamp as a DateTime, I store the date in a Date field type, and then I get the milliseconds of the day and store this as a Number.

I then construct the query for the search API using the numeric operators against these two fields, e.g.:

dayLastUpdated >= 2013-3-13 AND timeLastUpdated > 82884753

Numbat
  • 379
  • 2
  • 15