Re: How to sort on dates?

2017-12-24 Thread Georgios Petasis

Dear Erick,

Thanks for the idea, it doesn't work. It raises an exception that the 
value is missing the double() method.


Best,
George

Στις 18/12/2017 21:19, ο Erick Erickson έγραψε:

You _might_ (and I haven't tried this) be able to use sorting by
funtion with min/max for a date range field, see: "Sort by Function"
here: https://lucene.apache.org/solr/guide/6_6/function-queries.html.


On Mon, Dec 18, 2017 at 5:09 AM, Michael Kuhlmann  wrote:

Am 16.12.2017 um 19:39 schrieb Georgios Petasis:

Even if the DateRangeField field can store a range of dates, doesn't
Solr understand that I have used single timestamps?

No. It could theoretically, but sorting just isn't implemented in
DateRangeField.


I have even stored the dates.
My problem is that I need to use the query formating stated in the
documentation:
https://lucene.apache.org/solr/guide/7_1/working-with-dates.html#date-range-formatting

For example, if "financialYear" is a date range, I can do
q=financialYear:2014 and it will return everything that has a date
within 2014. If the field is date point, will it work?

Yes, just query with the plain old range syntax:
q=financialYear:[2014-01-01T00:00:00.000Z TO 2015-01-01T00:00:00.000Z}

DateRangeField might be slightly faster for such queries, but that
doesn't really matter much. I only used normal date fields yet, usually
they're fast enough.

As a rule of thunb, only use DateRangeField if you really need to index
date ranges.

-Michael





Re: How to sort on dates?

2017-12-24 Thread Georgios Petasis

Στις 18/12/2017 15:09, ο Michael Kuhlmann έγραψε:

Am 16.12.2017 um 19:39 schrieb Georgios Petasis:

Even if the DateRangeField field can store a range of dates, doesn't
Solr understand that I have used single timestamps?

No. It could theoretically, but sorting just isn't implemented in
DateRangeField.


I have even stored the dates.
My problem is that I need to use the query formating stated in the
documentation:
https://lucene.apache.org/solr/guide/7_1/working-with-dates.html#date-range-formatting

For example, if "financialYear" is a date range, I can do
q=financialYear:2014 and it will return everything that has a date
within 2014. If the field is date point, will it work?

Yes, just query with the plain old range syntax:
q=financialYear:[2014-01-01T00:00:00.000Z TO 2015-01-01T00:00:00.000Z}

DateRangeField might be slightly faster for such queries, but that
doesn't really matter much. I only used normal date fields yet, usually
they're fast enough.

As a rule of thunb, only use DateRangeField if you really need to index
date ranges.

-Michael


Hi all,

I tried to create an index that uses DatePointField for dates. Now the 
query "financialYear:2014" raises an error:


Invalid Date String:'2014'

On the other hand, with DateRangeField it works. And since I cannot 
restrict users (to not send only years like 2014), I cannot use 
DatePointField.


I am starting to think that there is no alternative than using both, one 
for queries and the other for sorting.


Is there a reason Solr does not understand "[2014 TO 2016]" in 
DatePointField as it does for DatePointField?


Best,

George