MCPcopy Create free account
hub / github.com/django-haystack/django-haystack / run_mlt

Method run_mlt

haystack/backends/__init__.py:599–622  ·  view source on GitHub ↗

Executes the More Like This. Returns a list of search results similar to the provided document (and optionally query).

(self, **kwargs)

Source from the content-addressed store, hash-verified

597 self._spelling_suggestion = results.get("spelling_suggestion", None)
598
599 def run_mlt(self, **kwargs):
600 """
601 Executes the More Like This. Returns a list of search results similar
602 to the provided document (and optionally query).
603 """
604 if self._more_like_this is False or self._mlt_instance is None:
605 raise MoreLikeThisError(
606 "No instance was provided to determine 'More Like This' results."
607 )
608
609 search_kwargs = {"result_class": self.result_class}
610
611 if self.models:
612 search_kwargs["models"] = self.models
613
614 if kwargs:
615 search_kwargs.update(kwargs)
616
617 additional_query_string = self.build_query()
618 results = self.backend.more_like_this(
619 self._mlt_instance, additional_query_string, **search_kwargs
620 )
621 self._results = results.get("results", [])
622 self._hit_count = results.get("hits", 0)
623
624 def run_raw(self, **kwargs):
625 """Executes a raw query. Returns a list of search results."""

Callers 2

get_countMethod · 0.95
get_resultsMethod · 0.95

Calls 5

build_queryMethod · 0.95
MoreLikeThisErrorClass · 0.90
getMethod · 0.80
updateMethod · 0.45
more_like_thisMethod · 0.45

Tested by

no test coverage detected