first I think the requirement is a bad one. Why should a document with low relevance 29 days ago score higher than the perfect document from 31 days ago? That doesn't seem like it serves the user very well...
And then "However in cases where update date is unavailable I need to sort it using created date." Does that mean if a doc has no update date but does have a created date 10 days ago you want to sort it before any docs older than 30 days? If so the simplest bit here would be to insure that any incoming doc has an update date by copying the created date into the update field if there is no update field. Now, all that aside, you sort by date with function queries. And function queries can have if clauses. So your sort function will be a big long set of if statements giving a boost to docs in your ranges. Or you can make your own function query plugin that would undoubtedly be more efficient. See the ref guide for "function queries". But again, I think this is a case where if you present the people who came up with this requirement with an explanation of the effects, you may just be able to sort by giving weight to more recent documents and be done with it. See: https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_boost_the_score_of_newer_documents Best, Erick On Mon, Mar 13, 2017 at 7:17 PM, Atita Arora <atitaar...@gmail.com> wrote: > Hi all, > > I am trying to resolve a problem here where I have to fiddle around with > set of dates ( created and updated date). > My use is that I have to make sure that the document with latest (recent) > update date should come higher in my search results. > Precisely, I am required to maintain 3 buckets wherein documents with > updated date falling in range of last 30 days should have maximum weight, > followed by update date in 60 and 90 and the rest. > However in cases where update date is unavailable I need to sort it using > created date. > I am not sure how do I achieve this. > Any insights here would be a great help. > Thanks in advance. > Regards, > Atita