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 Wesley Small <We...@mtvstaff.com> on 2009/04/21 18:57:22 UTC

Solr - clarification on date & sortable fields

I am sending this question out on behalf a college. Which needs a
clarification on solr indexing on  date and sortable fields.

We have declared a field date in schema.xml like below

<field name="premierDate_dt" type="date" indexed="true"  stored="true"
multiValued="false" default="NOW"/>

While indexing if I don't pass any value to this field like
<premierDate_dt/> or <premierDate_dt></premierDate_dt>, I am  getting the
below error 

SEVERE:  org.apache.solr.common.SolrException: Invalid Date String:''
>        at  org.apache.solr.schema.DateField.parseMath(DateField.java:167)
>        at  org.apache.solr.schema.DateField.toInternal(DateField.java:138)
>        at  org.apache.solr.schema.FieldType.createField(FieldType.java:179)
>        at  org.apache.solr.schema.SchemaField.createField(SchemaField.java:93)
>        at  
> org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:243)
>        at  
> org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProces
> sorFactory.java:58)
> 

Instead if I remove the tag from the request, it is not giving any  issues.
The same behavious exist for sortable fields as well like sint, slong.  Is
there any work around we can make in schema file?

Or the request needs to be changed accordingly?

A  quick work around for this is declaring the fields as string. But the
limitation would be we can not perform any range search queries on these
fields..

Interestingly,f we replace with all zeros in the date (I.e.
<premierDate_dt>0000-00-00T00:00:00Z</premierDate_dt>,
It gets indexed and the value in index is created as 0002-11-30T00:00:00.


Thanks.


Re: Solr - clarification on date & sortable fields

Posted by Otis Gospodnetic <ot...@yahoo.com>.
This all makes sense.  You are sending a blank string for a field that expects a date (or null - no element at all - if you want it to default to NOW).  So, yes, you need to either pass a valid date or don't pass that element in at all.


Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch



----- Original Message ----
> From: Wesley Small <We...@mtvstaff.com>
> To: "solr-user@lucene.apache.org" <so...@lucene.apache.org>
> Sent: Tuesday, April 21, 2009 12:57:22 PM
> Subject: Solr - clarification on date & sortable fields
> 
> I am sending this question out on behalf a college. Which needs a
> clarification on solr indexing on  date and sortable fields.
> 
> We have declared a field date in schema.xml like below
> 
> 
> multiValued="false" default="NOW"/>
> 
> While indexing if I don't pass any value to this field like
> or , I am  getting the
> below error 
> 
> SEVERE:  org.apache.solr.common.SolrException: Invalid Date String:''
> >        at  org.apache.solr.schema.DateField.parseMath(DateField.java:167)
> >        at  org.apache.solr.schema.DateField.toInternal(DateField.java:138)
> >        at  org.apache.solr.schema.FieldType.createField(FieldType.java:179)
> >        at  org.apache.solr.schema.SchemaField.createField(SchemaField.java:93)
> >        at  
> > org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:243)
> >        at  
> > org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProces
> > sorFactory.java:58)
> > 
> 
> Instead if I remove the tag from the request, it is not giving any  issues.
> The same behavious exist for sortable fields as well like sint, slong.  Is
> there any work around we can make in schema file?
> 
> Or the request needs to be changed accordingly?
> 
> A  quick work around for this is declaring the fields as string. But the
> limitation would be we can not perform any range search queries on these
> fields..
> 
> Interestingly,f we replace with all zeros in the date (I.e.
> 0000-00-00T00:00:00Z,
> It gets indexed and the value in index is created as 0002-11-30T00:00:00.
> 
> 
> Thanks.