[KinoSearch] Sorting by date

Marvin Humphrey marvin at rectangular.com
Thu Jan 7 05:16:12 PST 2010


On Thu, Jan 07, 2010 at 12:41:54PM +0000, Dermot wrote:

> If you want to sort by date, does the value supplied to spec_field
> need to be in a specific format? 

The standard technique is to use a sortable string format, e.g. "YYYY-MM-DD
HH:MM:SS" normalized to GMT.

FWIW, there's undocumented, experimental support for sortable numeric fields
(Int32Type, Int64Type, Float32Type, Float64Type) in the current release
(0.30_072).  Those FieldType classes aren't advertised because they cannot yet
be "indexed", but they can be "stored" and "sortable".  Eventually,
recommended practice for sorting by date will be to convert to a timestamp and
use an Int32Type (modulo the usual range caveats for 32-bit timestamps blah
blah blah).  See the test file t/511-sort_spec.t for example code if you're
interested.

> IE: should I convert my dates in UNIX timestamps so it's a straight numeric
> sort or is there some magic (yes I am lazy) that will accept a DateTime
> format?

No special handling for DateTime objects, and no plans to add any.

Marvin Humphrey




More information about the kinosearch mailing list