0

I have query in solr

I have date range list my indexed data"

from_datetimeList:["2021-08-27T00:00:00Z-2021-08-31T00:00:00Z", "2021-08-2T00:00:00Z-2021-08-12T00:00:00Z", "2021-08-25T02:21:00Z-2021-09-25T02:21:00Z"]

I need to write query such that if user want to find the userInputDate: "2021-08-25T03:21:00Z is lying in from_datetimeList ranges than return true else false.

this user userInputDate will keep changing as per the user's requirement

  • Have you seen https://solr.apache.org/guide/8_9/working-with-dates.html and the date range interval support? Also, this was already commented on another question you've asked about the same issue: https://stackoverflow.com/questions/69043153/issue-in-indexing-solr-data – MatsLindh Sep 06 '21 at 10:05
  • @MatsLindh Mats I am facing issue I am trying to index the range like '2021-08-30T12:00:00Z' TO 2021-08-30T15:00:00Z' in solr but it not coming when I am adding daterange in xml. could you please let me know the error – Anshul Verma Sep 07 '21 at 06:19
  • Add details to your question about exactly how your data is formatted on the way in; it needs to match the described format in the reference guide (so it's hard to say whether that `'` after `Z` is present or not, for example). – MatsLindh Sep 07 '21 at 06:25
  • I have added query in my DIH SELECT tl_id AS e_id, (CONCAT((CASE WHEN (t_date = '0000-00-00') THEN NULL ELSE (CONCAT(t_date, 'T', SEC_TO_TIME(MIN(st_time) * 60))) END), 'Z' TO ', (CASE WHEN (ticket_date = '0000-00-00') THEN NULL ELSE (CONCAT(t__date, 'T', SEC_TO_TIME(MAX(en_time) * 60))) END), 'Z')) slots_date_time_range FROM slots GROUP BY t_date – Anshul Verma Sep 07 '21 at 06:40
  • That doesn't seem like it'd be valid SQL; `), 'Z' TO ', ` would have a stray `'` - or is there a backslash missing because of the SO comment? I'm also guessing that you could have problems when there's a NULL on either side, but not on the other? Try to make it work by submitting manually formatted documents first – MatsLindh Sep 07 '21 at 06:48
  • Sql is returning me correct data, atleast it looks like correct one '2018-12-15T12:00:00Z TO 2018-12-15T16:00:00Z' and yes I'll handle that scnerio when the value is null – Anshul Verma Sep 07 '21 at 06:53
  • @MatsLindh yes you are right please ignore that 'Z' TO '. I am posting query again below – Anshul Verma Sep 07 '21 at 06:57
  • SELECT tl_id AS e_id, (CONCAT((CASE WHEN (t_date = '0000-00-00') THEN NULL ELSE (CONCAT(t_date, 'T', SEC_TO_TIME(MIN(st_time) * 60))) END), 'Z TO ', (CASE WHEN (t_date = '0000-00-00') THEN NULL ELSE (CONCAT(t_date, 'T', SEC_TO_TIME(MAX(en_time) * 60))) END), 'Z')) AS slots_date_time_range FROM t_slots GROUP BY t_date – Anshul Verma Sep 07 '21 at 06:57
  • Add the resulting document to your question together with field type definition and the query you're making, and what you expect the result to be. – MatsLindh Sep 07 '21 at 07:53
  • sql query for one event returning '2018-12-15T12:00:00Z TO 2018-12-15T16:00:00Z' add below line in schema - – Anshul Verma Sep 07 '21 at 09:01
  • Issue is I am not getting this field in indexed data. If I change the type to string in schema I can see the exact data – Anshul Verma Sep 07 '21 at 09:14

0 Answers0