SolR : More Like This on number fields

2019-07-02 01:36发布

问题:

I wonder if it is possible to configure mlt (more like this) to do the similarity on close numbers ?

For example, a document with the field numberOfParticipant at 10, i would like to have some similar documents with numberOfParticipant between 5 and 15.

Does this option exist ?

回答1:

FunctionQuery may be your solution http://wiki.apache.org/solr/FunctionQuery . I never used it myself, but this must be reasonably easy to code something like this:

10-|10-X| where |x| is the absolute value of x 

Sample values of X and output:
X  => Result
8     8
9     9
10    10
11    9
12    8

Then specify a boost for that function. In solr, you may need to code it like sub(10,abs(sub(10,X))).


But then if you actually wanted to categorize results as "less than 5", "5-15", "greater than 15", choose faceting http://wiki.apache.org/solr/SolrFacetingOverview



标签: solr