5

In Solr, I am wondering if it's possible to constrain/filter the "More Like This" result set from a standard (dismax) query - e.g., without having to use the specific MoreLikeThis request handler? For example, I have a Solr index which has documents for two countries. When I do my original (dismax) query, I use a field query operator (fq) to filter the results for the country of interest. But the MLT results that get returned are for both countries. I tried using the mlt.fl=country,name to indicate "show me more results that are similar in country and name" but it doesn't seem to obey the country criteria (or at least the name parameter far outweighs the country parameter).

I can't seem to find any Solr documentation that indicates there is an option for this, but I'm hoping one of you Solr experts out there may have some nifty tricks/hacks for this.

Thanks in advance!

javanna
  • 59,145
  • 14
  • 144
  • 125
cambo
  • 973
  • 4
  • 11
  • 22

1 Answers1

0

Solr mlt.fl is supposed to find Related Documents based on these fields. However, it is not obligated to do so like the NOT clause of fq. A workaround could be to exclude the country using fq param. So, your mlt query could become something like

/mlt?q=id:ID&fq=-country:COUNTRY&mlt.boost=true

ID: The document ID for which MLT needs to be calculated. COUNTRY: The country which you want to exclude.

pr4n
  • 2,918
  • 3
  • 30
  • 42
  • 1
    Thanks but this isn't quite what I was looking for, as I was hoping to avoid the MLT request handler. But after reading the documentation more closely, it seems that is not possible. From the Solr documentation wiki: "If you want to filter the similar results given by MoreLikeThis you have to use the MoreLikeThisHandler." (http://wiki.apache.org/solr/MoreLikeThis) – cambo Oct 03 '11 at 15:09
  • True. MLTComponent provides more flexibility and is recommended in case of complex situations. – pr4n Oct 03 '11 at 15:16