Στις 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