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 Dave Beckstrom <db...@collectivefls.com> on 2019/06/10 21:26:09 UTC

Sort date stored in text field?

Hi Everyone,

Running SOLR 7.3.1

I have a field called metatag.date that is field-type:
org.apache.solr.schema.TextField    The field is being populated by NUTCH,
which grabs the date from the html:

<meta name="date" id="date" content="2015-12-22 12:48:53" />

and stores it in the  metatag.date field in SOLR.

I'm trying to sort by date   (metatag.date desc) passed on the URL and it's
not working.

I don't think I have an option of using the field-type  DatePointField
because I have no way of formatting the date in the format:
1995-12-31T23:59:59Z

Anyone have any suggestions?

-- 
*Fig Leaf Software is now Collective FLS, Inc.*
*
*
*Collective FLS, Inc.* 

https://www.collectivefls.com/ <https://www.figleaf.com/>  





Re: Sort date stored in text field?

Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/10/2019 3:26 PM, Dave Beckstrom wrote:
> I have a field called metatag.date that is field-type:
> org.apache.solr.schema.TextField    The field is being populated by NUTCH,
> which grabs the date from the html:

<snip>

> I'm trying to sort by date   (metatag.date desc) passed on the URL and it's
> not working.

In general, sorting by a field using the TextField class is probably not 
going to do what you think it will.

Can you share the full field definition in the schema, and the fieldType 
definition for the type used in the field definition?

Probably what you'll need to do is copyField that to another field 
that's using the StrField class (usually defined as "string" in most 
schemas), and ensure it has docValues turned on.  For sorting, you could 
make it indexed="false" and stored="false" -- just enable docValues.

Thanks,
Shawn