0

Is there is any way to compare DateList with Date along with timestamp

eg I have indexed from_datetime in solr "from_datetime":["2021-08-27T00:00:00Z", "2021-08-12T00:00:00Z", "2021-08-25T02:21:00Z"]

and user input is "2021-08-25T03:21:00Z". How can I compare user input with from_datetime list

  • How do you want to compare these values? What are you trying to achieve? Since neither of your fields match, directly comparing it won't get any hits. – MatsLindh Sep 06 '21 at 07:38
  • I want to check if user input date is greater than the mention dates in from_datetime list eg "2021-08-25T03:21:00Z" is greater than "2021-08-25T02:21:00Z" – Anshul Verma Sep 06 '21 at 08:52
  • Than all the dates mentioned or greater than one of them? In the first case you should index a separate field with the latest date in it, so that the query can be resolved with a single lookup. You can either have this logic in your indexing code, or you can use an update processor for a specific field with the MaxFieldValue processor: https://solr.apache.org/docs/8_9_0//solr-core/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.html (and use a clone field processor to copy content into it) – MatsLindh Sep 06 '21 at 08:55
  • I am using DataIndexHandler with sql query to index. Also the user input date will vary – Anshul Verma Sep 06 '21 at 08:59
  • @MatsLindh Could you help in one more query https://stackoverflow.com/questions/69071978/find-particular-date-lying-in-the-daterangelist-at-solr. thanks – Anshul Verma Sep 06 '21 at 09:07
  • That's the exact same question. You need to index the maximum date to a separate field (depending on what your query look like in DIH, you can probably use `MAX()` to extract that value), then query against that field: `max_date_value:[ TO *]` will then give you any document that has a date higher than what the user entered. In fact, if you _only_ want to find documents that have a higher value, you don't even need the max field, you can use what you have today. `from_datetime:[ TO *]` – MatsLindh Sep 06 '21 at 09:34
  • Sorry, I was a bit quick about the other question; it's not the same. – MatsLindh Sep 06 '21 at 10:05

0 Answers0