You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gérard Dupont <ge...@gmail.com> on 2009/09/08 10:51:23 UTC

date field

Hi all,

I'm currently facing a little difficulty to index and search on date field.
The indexing is done in the right way (I guess) and I can find valid date in
the field like "2009-05-01T12:45:32Z". However when I'm searching the user
don't always give an exact date. for instance they give "2008-05-01" to get
all documents related to that day.  I can do a trick using wildcard but is
there another way to do it ? Moreover if they give the full date string (or
if I hack the query parser) I can have the full syntax, but then the ":"
annoy me because the Lucene parser does not allow it without quotes. Any
ideas ?

-- 
Gérard Dupont
Information Processing Control and Cognition (IPCC) - EADS DS
http://weblab.forge.ow2.org

Document & Learning team - LITIS Laboratory

Re: date field

Posted by Chris Hostetter <ho...@fucit.org>.
: the field like "2009-05-01T12:45:32Z". However when I'm searching the user
: don't always give an exact date. for instance they give "2008-05-01" to get

whatever date your users give you, you'll need to format it in the full 
ISO format in order to query on it (ie: 2008-05-01 into 
2008-05-01T00:00:00Z)

but once you do that, you can append date math syntax to query for a range 
some range arround your value

yourField:[2008-05-01T00:00:00Z/DAY TO 2008-05-01T00:00:00Z/DAY+1DAY-1MILLISECOND]

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



-Hoss


Re: date field

Posted by Israel Ekpo <is...@gmail.com>.
Hi Gérard,

Concerning the issue with the ":" character you can use the
ClientUtils.escapeQueryChars() method to handle special characters that are
part of the query syntax.

The complete list of special characters is in the source code.

check out the following resources

org/apache/solr/client/solrj/util/ClientUtils.java

http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Escaping%20Special%20Characters


2009/9/8 Gérard Dupont <ge...@gmail.com>

> Hi all,
>
> I'm currently facing a little difficulty to index and search on date field.
> The indexing is done in the right way (I guess) and I can find valid date
> in
> the field like "2009-05-01T12:45:32Z". However when I'm searching the user
> don't always give an exact date. for instance they give "2008-05-01" to get
> all documents related to that day.  I can do a trick using wildcard but is
> there another way to do it ? Moreover if they give the full date string (or
> if I hack the query parser) I can have the full syntax, but then the ":"
> annoy me because the Lucene parser does not allow it without quotes. Any
> ideas ?
>
> --
> Gérard Dupont
> Information Processing Control and Cognition (IPCC) - EADS DS
> http://weblab.forge.ow2.org
>
> Document & Learning team - LITIS Laboratory
>



-- 
"Good Enough" is not good enough.
To give anything less than your best is to sacrifice the gift.
Quality First. Measure Twice. Cut Once.

Re: date field

Posted by Gérard Dupont <ge...@gmail.com>.
Thanks for the answer.

However we don't have strong performance issue (for now) and it that case,
how do you face query where time part is missing ?

On Tue, Sep 8, 2009 at 17:44, Silent Surfer <si...@yahoo.com>wrote:

> Hi,
>
> If you are still not went live already, I would suggest to use the long
> instead of date field. According to our testing, search based on date fields
> are very slow when compared to search based on long field.
>
> You can use System.getTimeInMillis() to get the time
> When showing it to the user, apply a date formatter.
>
> When taking input from user, let him enter whatever the date he wants to
> and then you can convert to "long" and do your searches based on it.
>
> Experts can pitch in with any other ideas..
>
> Thanks,
> sS
>

Re: date field

Posted by Silent Surfer <si...@yahoo.com>.
Hi,

If you are still not went live already, I would suggest to use the long instead of date field. According to our testing, search based on date fields are very slow when compared to search based on long field.

You can use System.getTimeInMillis() to get the time
When showing it to the user, apply a date formatter.

When taking input from user, let him enter whatever the date he wants to and then you can convert to "long" and do your searches based on it.

Experts can pitch in with any other ideas..

Thanks,
sS

--- On Tue, 9/8/09, Gérard Dupont <ge...@gmail.com> wrote:

> From: Gérard Dupont <ge...@gmail.com>
> Subject: date field
> To: solr-user@lucene.apache.org
> Cc: "Nicolas Bureau" <ni...@gmail.com>
> Date: Tuesday, September 8, 2009, 8:51 AM
> Hi all,
> 
> I'm currently facing a little difficulty to index and
> search on date field.
> The indexing is done in the right way (I guess) and I can
> find valid date in
> the field like "2009-05-01T12:45:32Z". However when I'm
> searching the user
> don't always give an exact date. for instance they give
> "2008-05-01" to get
> all documents related to that day.  I can do a trick
> using wildcard but is
> there another way to do it ? Moreover if they give the full
> date string (or
> if I hack the query parser) I can have the full syntax, but
> then the ":"
> annoy me because the Lucene parser does not allow it
> without quotes. Any
> ideas ?
> 
> -- 
> Gérard Dupont
> Information Processing Control and Cognition (IPCC) - EADS
> DS
> http://weblab.forge.ow2.org
> 
> Document & Learning team - LITIS Laboratory
>