Search code examples
solrsolrj

How to get the record by comparing the date field


In my Solr, there are tow records:

ID  name document_date
--  ---- -------------
1   A     20/12/2013
2   A     24/12/2013

How can I use the Solr query to retrieve only the record (ID=2) with the latest document date (document_date='24/12/2013')?


Solution

  • Now your question makes sense to me.

    You need to use the FieldCollapsing feature in SOLR.

    You can get the feature in below link:

    https://cwiki.apache.org/confluence/display/solr/Result+Grouping

    Using above feature you can 1 or N documnets to user from a particular group and you can also view all other documents by firing a particular query.

    You will also have to apply sortby document_date to get the lates document on the top.

    Then you will get the latest document at the top.

    Regards,

    Jayesh Bhoyar

    http://technical-fundas.blogspot.in/2014/06/zookeeper-cluster-setup.html