MCPcopy Index your code
hub / github.com/django-haystack/django-haystack / SearchQuerySet

Class SearchQuerySet

haystack/query.py:13–633  ·  view source on GitHub ↗

Provides a way to specify search parameters and lazily load results. Supports chaining (a la QuerySet) to narrow the search.

Source from the content-addressed store, hash-verified

11
12
13class SearchQuerySet:
14 """
15 Provides a way to specify search parameters and lazily load results.
16
17 Supports chaining (a la QuerySet) to narrow the search.
18 """
19
20 def __init__(self, using=None, query=None):
21 # ``_using`` should only ever be a value other than ``None`` if it's
22 # been forced with the ``.using`` method.
23 self._using = using
24 self.query = None
25 self._determine_backend()
26
27 # If ``query`` is present, it should override even what the routers
28 # think.
29 if query is not None:
30 self.query = query
31
32 self._result_cache = []
33 self._result_count = None
34 self._cache_full = False
35 self._load_all = False
36 self._ignored_result_count = 0
37 self.log = logging.getLogger("haystack")
38
39 def _determine_backend(self):
40 # A backend has been manually selected. Use it instead.
41 if self._using is not None:
42 self.query = connections[self._using].get_query()
43 return
44
45 # No backend, so rely on the routers to figure out what's right.
46 hints = {}
47
48 if self.query:
49 hints["models"] = self.query.models
50
51 backend_alias = connection_router.for_read(**hints)
52
53 # The ``SearchQuery`` might swap itself out for a different variant
54 # here.
55 if self.query:
56 self.query = self.query.using(backend_alias)
57 else:
58 self.query = connections[backend_alias].get_query()
59
60 def __getstate__(self):
61 """
62 For pickling.
63 """
64 len(self)
65 obj_dict = self.__dict__.copy()
66 obj_dict["_iter"] = None
67 obj_dict["log"] = None
68 return obj_dict
69
70 def __setstate__(self, data_dict):

Callers 15

__init__Method · 0.90
get_resultsMethod · 0.90
get_search_querysetMethod · 0.90
renderMethod · 0.90
update_backendMethod · 0.90
test_countMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
test_modelsMethod · 0.90
test_load_allMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_countMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
test_modelsMethod · 0.72
test_load_allMethod · 0.72
test_usingMethod · 0.72
setUpMethod · 0.72
test_narrow_sqMethod · 0.72
setUpMethod · 0.72