Oops... I meant to say that Solr doesn't *index* the trailing Z, but it is "stored" (the stored value, not the indexed value.) The query must match the indexed value, not the stored value.

-- Jack Krupansky

-----Original Message----- From: Jack Krupansky
Sent: Wednesday, May 02, 2012 11:55 AM
To: solr-user@lucene.apache.org
Subject: Re: question about dates

The trailing "Z" is required in your input data to be indexed, but the Z is
not actually stored. Your query must have the trailing "Z" though, unless
you are doing a wildcard or prefix query.

-- Jack Krupansky

-----Original Message----- From: G.Long
Sent: Wednesday, May 02, 2012 11:18 AM
To: solr-user@lucene.apache.org
Subject: question about dates

Hi :)

I'm starting to use Solr and I'm facing a little problem with dates. My
documents have a date property which is of type 'yyyyMMdd'.

To index these dates, I use the following code:

String dateString = "20101230";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = sdf.parse(dateString);
doc.addField("date", date);

In the index, the date "20101230" is saved as "2010-12-29T23:00:00Z" (
because of GMT).

Now I would like to query documents which have their date property
equals to "20101230" but I don't know how to handle this.

I tried the following code :

String dateString = "20101230";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = sdf.parse(dateString);
SimpleDateFormat gmtSdf = new
SimpleDateFormat("yyyy-MM-dd'T'HH\\:mm\\:ss'Z'");
String gmtString = gmtSdf.format(Date);

The problem is that gmtString is equals to "2010-12-30T00\:00\:00Z".
There is a difference between the index value and the parameter value of
my query : /.

I see that there might be something to do with the timezones during the
date to string  and string to date conversion but I can't find it.

Thanks,

Gary




Reply via email to