On 4/17/2019 8:45 PM, Anuj Bhargava wrote:
I have an issue while searching on the Date field date_upload
My Schema file has the following entry for DATE Field
*<field name="date_upload" type="pdate" indexed="true" stored="true"/>*
You haven't shown us the definition for pdate.
If it is what the Solr examples have, then it is a DatePointField.
My data-config.xml has the following entry -
My assumption would be that in mysql, fields like date_upload are mysql
date fields with timestamp. If they are date-only fields in mysql, then
DatePointField might not work - you would need to use DateRangeField as
the class, which you changed it to in your followup message.
*The following do not work -*
fq=date_upload:NOW (does not work)
http://localhost:8983/solr/Nlive/select?fq=date_c%3ANOW&q=*%3A*
fq=date_upload:NOW-1DAY (does not work)
fq=date_upload:(NOW-30DAYS) (does not work)
What *EXACTLY* do you mean when you say "does not work"? One thing I
can tell you is that using NOW in this way means that you are searching
for an exact time -- to the millisecond. If that exact time is not
found in the field, then you will get no results ... and chances are
that the exact time returned by any of these three queries does NOT
exist in the field. Results would be the same with DateRangeField as
with DatePointField with these types of queries.
fq=date_upload:[2018-12-01T:00:00:00Z TO 2019-04-17T00:00:00Z] (does not
work)
*"msg":"Invalid Date in Date Math String:'2018-12-01T:00:00:00Z'",*
I would expect this to work. The message is very odd ... I wonder if
any of the characters that were sent are not the actual ascii characters
but some kind of unicode character that looks the same but isn't the
right one.
fq=date_upload:[2018-12-01 TO 2019-04-17] Gives the following error
Indeed this kind of query will not work on DatePointField. But it will
work on DateRangeField.
*However this does give results -*
fq=date_upload:[* TO NOW]
http://localhost:8983/solr/Nlive/select??fq=date_c%3A%5B*%20TO%20NOW%5D&q=*%3A*
I would expect this query to work on both field types.
Thanks,
Shawn