質問

I was trying to use the MLT (more like this) feature of SOLR but was stuck on how to use the filtering of related content. For e.g My documents in solr have following different categories sports, entertainment, funny, busiseness etc

I want related stuff (based on user query) for each category. Thus I would like to filter the MLT results of solr cased on category type. Can I somehow filter results?

If not possible, can I somehow use solr function query to make sure related stuff are grouped by category?

Thanks.

役に立ちましたか?

解決

Need to define a /mlt request handler and then use fq= for filterting the query for MLT

他のヒント

In the solrconfig.xml definition, you should define a request handler as follows:

<requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
</requestHandler>

Then you need to make a request to this handler where you specify the "fq" parameter. This will filter your MoreLikeThis (MLT) results. See the following example where documentid is the ID of the document on which you want to find similar results and searchtext is the field that you use to compare whether two documents are similar or not. "rows" is the number of MLT results that the request should return.

'http://solrserver.local:4562/solr/mlt?rows=2&fl=id&mlt.fl=searchtext&fq=category:<category>&q=id:<documentid>',

See the Filter Query documentation: https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-Thefq(FilterQuery)Parameter

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top