Am 13.02.2015 um 11:18 schrieb Gonzalo Rodriguez:

> You can always change the type of your sortyear field to an int, or create an 
> int version of it and use copyField to populate it.

But that would require me to reindex. Would be nice to have some type
conversion available within a function query.

> And using NOW/YEAR will round the current date to the start of the year, you 
> can read more about this in the Javadoc: 
> http://lucene.apache.org/solr/4_10_3/solr-core/org/apache/solr/util/DateMathParser.html
> 
> You can test it using the example collection: 
> http://localhost:8983/solr/collection1/select?q=*:*&boost=recip(ms(NOW/YEAR,manufacturedate_dt),3.16e-11,1,1)&fl=id,manufacturedate_dt,score,[explain]&defType=edismax
>  and checking the explain field for the numeric value given to NOW/YEAR vs 
> NOW/HOUR, etc.

The definition of *_dt fields int the example-schema is 'date' but my
field is text or (t)int if I have to reindex.

To compare against this int field I need another (comparable) int.
ms(NOW/YEAR,manufacturedate_dt) is an int, but a huge one, which is very
difficult to bring into a sensible relationship to e.g. '2015'.

Your suggestion would only work if I change my year to a date like
2015-01-01T00:00:00Z which is not a sensible format for a publication
year and not even easily creatable by copyfield.

What I need is a real year number, not a date truncated to the year,
which is only accessible as the number of milliseconds since the epoch
of Jan, 1st 00:00:00h, which is not very handy.

-Michael

Reply via email to