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 "Dan A. Dickey" <da...@savvis.net> on 2009/10/22 17:11:14 UTC

date searching?

Hi,
I'm having a slight problem with date searching...
I have a document indexed with a date type using the value "2007-07-07T00:00:00Z".
However, when searching - the parser doesn't seem to like this.
How should I be able to search for it?

In the select query searching for "Date:2007-07-07T00:00:00Z" gets me
an http error 400 and some text:
	Problem accessing /solr/select. Reason:
		Invalid Date String:'2007-07-07T00'

Searching for "Date:[2007-07-07T00:00:00Z]" gets me a syntax error
because the parser is looking for a " TO " and another date.

Searching for "Date:[2007-07-07T00:00:00Z TO 2007-07-07T00:00:00Z+1DAY]"
gets me my document back.

So... is this just a solr bug, or a bug in my search syntax?
Or maybe something incorrect in my schema.xml?  Or solrconfig.xml?
Help please.  :)
	-Dan

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net

Re: date searching?

Posted by "Dan A. Dickey" <da...@savvis.net>.
On Thursday 22 October 2009 11:25:20 am AHMET ARSLAN wrote:
> > Hi,
> > I'm having a slight problem with date searching...
> > I have a document indexed with a date type using the value
> > "2007-07-07T00:00:00Z".
> > However, when searching - the parser doesn't seem to like
> > this.
> > How should I be able to search for it?
> > 
> > In the select query searching for
> > "Date:2007-07-07T00:00:00Z" gets me
> > an http error 400 and some text:
> >     Problem accessing /solr/select. Reason:
> >         Invalid Date
> > String:'2007-07-07T00'
> > 
> > Searching for "Date:[2007-07-07T00:00:00Z]" gets me a
> > syntax error
> > because the parser is looking for a " TO " and another
> > date.
> > 
> > Searching for "Date:[2007-07-07T00:00:00Z TO
> > 2007-07-07T00:00:00Z+1DAY]"
> > gets me my document back.
> > 
> > So... is this just a solr bug, or a bug in my search
> > syntax?
> > Or maybe something incorrect in my schema.xml?  Or
> > solrconfig.xml?
> > Help please.  :)
> >     -Dan
> 
> Not it is not a bug.
> Chracter : is a part of QueryParser syntax, so you need to escape it.
> Try this :
> Date:2007-07-07T00\:00\:00Z
> or this :
> Date:"2007-07-07T00:00:00Z" 
> 
> I use the second one since it is easy to insert quotes. 
> They both will give you what you want. 

Ahmet,
Thank you very much!  That did it.
I was wondering about those colons in the string at some
point, but didn't carry the thought out through the process...
Thanks again!
	-Dan

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net

Re: date searching?

Posted by AHMET ARSLAN <io...@yahoo.com>.
> Hi,
> I'm having a slight problem with date searching...
> I have a document indexed with a date type using the value
> "2007-07-07T00:00:00Z".
> However, when searching - the parser doesn't seem to like
> this.
> How should I be able to search for it?
> 
> In the select query searching for
> "Date:2007-07-07T00:00:00Z" gets me
> an http error 400 and some text:
>     Problem accessing /solr/select. Reason:
>         Invalid Date
> String:'2007-07-07T00'
> 
> Searching for "Date:[2007-07-07T00:00:00Z]" gets me a
> syntax error
> because the parser is looking for a " TO " and another
> date.
> 
> Searching for "Date:[2007-07-07T00:00:00Z TO
> 2007-07-07T00:00:00Z+1DAY]"
> gets me my document back.
> 
> So... is this just a solr bug, or a bug in my search
> syntax?
> Or maybe something incorrect in my schema.xml?  Or
> solrconfig.xml?
> Help please.  :)
>     -Dan

Not it is not a bug.
Chracter : is a part of QueryParser syntax, so you need to escape it.
Try this :
Date:2007-07-07T00\:00\:00Z
or this :
Date:"2007-07-07T00:00:00Z" 

I use the second one since it is easy to insert quotes. 
They both will give you what you want.