views:

607

answers:

1

My Lucene/Solr database contains a date column (created_at) that I need to use as a condition in a query.

I'm new to RoR and assume that RoR automatically uses its own date object upon anyObject.save, and that Solr in turn reindexes that column in its own way.

Regardless, the date is in this format: "2008-06-03 11:15:20"

I can write a quick parser to parse my query string into the above format, but when I query

Object.find(keyword:foo created_at >= '2008-06-03 11:15:20')

Solr throws a parsing error. I've tried several standard variations on this without success. Any suggestions?

+1  A: 

I hate to ask the obvious, but have you checked the solr docs for the query language for dates?

http://wiki.apache.org/solr/SolrQuerySyntax

and experience suggests that ">=" is not a valid solr operator. You can do range queries on date fields, but using the correct format with your example query would be:

Object.find("keyword:foo AND created_at:[2008-06-03T11:15:20.000Z TO *]")
Lee