Haystack more_like_this returns everything

I use Django, haystack, solr to search. I can search, and now I would like to find similar items using more_like_this. When I try to use the more_like_this function, I return all objects related to the type of the model, and not just those that correspond to it. Here is some code to show you how I use it:

def resource_view(request, slug):
    resource = Resource.objects.get(slug=slug)
    versions = Version.objects.get_for_object(resource)
    related = SearchQuerySet().more_like_this(resource)
    add_comment_form = AddCommentForm()
    return render_to_response('resources/resource.html',
                              {'resource': resource,
                               'versions': versions,
                               'related': related,
                               'add_comment_form': add_comment_form},
                              context_instance=RequestContext(request))

Apparently I need to include mlt in the solrconfig.xml file. Does anyone know how to do this, or a useful article / tutorial?

+1
source share
1 answer

obsolete question, but here is the answer anyway:

, , (MLT), solr. , - solrconfig.xml SOLR (Tomcat):

<requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
<lst name="defaults">
  <str name="mlt.mintf">1</str>
  <str name="mlt.mindf">1</str>
  <str name="mlt.minwl">3</str>
  <str name="mlt.maxwl">15</str>
  <str name="mlt.maxqt">20</str>
  <str name="mlt.match.include">false</str>
</lst>
</requestHandler>
+3

Source: https://habr.com/ru/post/1535753/


All Articles