MCPcopy
hub / github.com/redis/redis-py / Query

Class Query

redis/commands/search/query.py:6–339  ·  view source on GitHub ↗

Query is used to build complex queries that have more parameters than just the query string. The query string is set in the constructor, and other options have setter functions. The setter functions return the query object so they can be chained. i.e. `Query("foo").verbatim().f

Source from the content-addressed store, hash-verified

4
5
6class Query:
7 """
8 Query is used to build complex queries that have more parameters than just
9 the query string. The query string is set in the constructor, and other
10 options have setter functions.
11
12 The setter functions return the query object so they can be chained.
13 i.e. `Query("foo").verbatim().filter(...)` etc.
14 """
15
16 def __init__(self, query_string: str) -> None:
17 """
18 Create a new query object.
19 The query string is set in the constructor, and other options have
20 setter functions.
21 """
22
23 self._query_string: str = query_string
24 self._offset: int = 0
25 self._num: int = 10
26 self._no_content: bool = False
27 self._no_stopwords: bool = False
28 self._fields: Optional[List[str]] = None
29 self._verbatim: bool = False
30 self._with_payloads: bool = False
31 self._with_scores: bool = False
32 self._scorer: Optional[str] = None
33 self._filters: List = list()
34 self._ids: Optional[Tuple[str, ...]] = None
35 self._slop: int = -1
36 self._timeout: Optional[float] = None
37 self._in_order: bool = False
38 self._sortby: Optional[SortbyField] = None
39 self._return_fields: List = []
40 self._return_fields_decode_as: dict = {}
41 self._summarize_fields: List = []
42 self._highlight_fields: List = []
43 self._language: Optional[str] = None
44 self._expander: Optional[str] = None
45 self._dialect: int = DEFAULT_DIALECT
46
47 def query_string(self) -> str:
48 """Return the query string of this query only."""
49 return self._query_string
50
51 def limit_ids(self, *ids) -> "Query":
52 """Limit the results to a specific set of pre-known document
53 ids of any length."""
54 self._ids = ids
55 return self
56
57 def return_fields(self, *fields) -> "Query":
58 """Add fields to return fields."""
59 for field in fields:
60 self.return_field(field)
61 return self
62
63 def return_field(

Callers 15

search_vss.pyFile · 0.90
query_geo.pyFile · 0.90
home_json.pyFile · 0.90
query_em.pyFile · 0.90
query_ft.pyFile · 0.90
geo_index.pyFile · 0.90
query_range.pyFile · 0.90
query_combined.pyFile · 0.90
test_clientMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_clientMethod · 0.72
test_scoresMethod · 0.72
test_stopwordsMethod · 0.72
test_filtersMethod · 0.72
test_sort_byMethod · 0.72
test_exampleMethod · 0.72
test_no_indexMethod · 0.72
test_summarizeMethod · 0.72
test_alter_schema_addMethod · 0.72