Currently I want to sort based on relevance score (matching), but sometimes user might want to sort by content freshness (creation date), so I also want to sort content as fresh as possible.
So, there’s two thing to be order by here: Matching score and entity creation date.
Current documented multi-sort is sort by score first, then when the same score happen for multiple entities, then we will sort again based on freshness.
But I think in many cases, that relevance will win over freshness. So multiple old entity with high relevance score will appear on top of the result.
My proposed solution is: We gonna order by creation date first, then select top n result, for example top 100 entities, which will be temporary table. Then we’ll apply matching score sorting to that temporary table instead of entire result set. That will somewhat guarantee freshness of result.
Is that something can be done with Hibernate Search ? Backend is Apache Lucene.