Search code examples
javasearchsolrlucenesimilarity

Find least similar/relevant document with Lucene


Is it possible to kind of revert the scoring functionality in Lucene such that a search returns the least similar documents in the index?

Specifically, I want to execute a MoreLikeThis Query (the query itself is a document) and instead of getting the most relevant documents, it shoud return the least relevant/similar documents.

How would this be achievable? Thank you!


Solution

  • You can always sort by "score, asc": ascending instead of descending.

    Keep in mind that in order to be considered at all, there must be at least be some similarity or else the doc won't be in the recall at all.

    Or you can negate the query: filter out all docs that are "like this". Sorting then becomes pointless, as these docs are all equally (fully) distinct from the query.