i'm facing a big problem in my SolR DB. My objects have a datetime field "Available_From" and a datetime field "Available_To". We also have a "Ranking" field for the sorting. I can search correctly with direct queries (eg. give me all the items that are available at the moment) but when i do a regular search i cannot find a way to show the items that result "available NOW" in the first places in the results, usually sorted by "Ranking" field. How can i do this? Am I forced to write some java classes (the nearest thing i've found is there https://medium.com/@devchaitu18/sorting-based-on-a-custom-function-in-solr-c94ddae99a12) or is there a way to do with standard SolR queries? Thanks in advance to everyone!
In your case you actually don't want sorting, since that indicates that you want one field to determine the returned sequence of documents.
Instead, use boosting - apply a very large boost to those that are available now, either through bq
or boost
, then apply a boost based on ranking. You'll have to tweak the weights given to each part based on how you want the search results to be presented.