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 duddy67 <sa...@littlemarc.com> on 2011/07/07 10:38:36 UTC

The correct query syntax for date ?

Hi,

I have a syntax problem in my query with the SOLR date format.
This is what I type:

q=datecreation:2001-10-11

but SOLR returns me an error message:

Invalid Date String:'2001-10-11'

I tried different combinations but none of them works.
Someone could tells me what is the correct syntax ?


Thanks for advance.

--
View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147532p3147532.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: The correct query syntax for date ?

Posted by duddy67 <sa...@littlemarc.com>.
It works. 
Thanks.

--
View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147536p3149588.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: The correct query syntax for date ?

Posted by Erick Erickson <er...@gmail.com>.
right, you have to escape the ':' in the date, those are Lucene
query syntax characters. Try:
q=datecreation:2001-10-11T00\:00\:00Z

On Thu, Jul 7, 2011 at 10:36 AM, duddy67 <sa...@littlemarc.com> wrote:
> I allready tried the format:
>
> q=datecreation:2001-10-11T00:00:00Z
>
> but I still get the same error message.
>
> I use the 1.4.1 version. Is this the reason of my pb ?
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147536p3148384.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: The correct query syntax for date ?

Posted by duddy67 <sa...@littlemarc.com>.
I allready tried the format: 

q=datecreation:2001-10-11T00:00:00Z

but I still get the same error message.

I use the 1.4.1 version. Is this the reason of my pb ? 

--
View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147536p3148384.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: The correct query syntax for date ?

Posted by Erick Erickson <er...@gmail.com>.
Well, just search for "date field" in schema.xml (assuming a recent
version of Solr, you haven't told us what version you're using).

The "green" assumes you're using an editor that highlights comments
in an XML file.

But all the information you need is right there in Ahmet's e-mail. Dates
are represented as 1995-12-31T23:59:59Z. Look at
http://lucene.apache.org/solr/api/org/apache/solr/schema/DateField.html

(first hit when googling "solr date").

Best
Erick

On Thu, Jul 7, 2011 at 7:33 AM, duddy67 <sa...@littlemarc.com> wrote:
> Thanks but I'm still lost.
> I didn't see any green colored comments.
> Could you show me a concrete example of a date query ?
>
> Thanks
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147536p3147890.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: The correct query syntax for date ?

Posted by duddy67 <sa...@littlemarc.com>.
Thanks but I'm still lost.
I didn't see any green colored comments.
Could you show me a concrete example of a date query ?

Thanks

--
View this message in context: http://lucene.472066.n3.nabble.com/The-correct-query-syntax-for-date-tp3147536p3147890.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: The correct query syntax for date ?

Posted by Ahmet Arslan <io...@yahoo.com>.
> I have a syntax problem in my query with the SOLR date
> format.
> This is what I type:
> 
> q=datecreation:2001-10-11
> 
> but SOLR returns me an error message:
> 
> Invalid Date String:'2001-10-11'
> 
> I tried different combinations but none of them works.
> Someone could tells me what is the correct syntax ?

Please see the green colored comments in example schema.xml:

"The format for this date field is of the form 1995-12-31T23:59:59Z, and
         is a more restricted form of the canonical representation of dateTime
         http://www.w3.org/TR/xmlschema-2/#dateTime    
         The trailing "Z" designates UTC time and is mandatory....."