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

Class Search

redis/commands/search/__init__.py:16–113  ·  redis/commands/search/__init__.py::Search

Create a client for talking to search. It abstracts the API of the module and lets you just use the engine.

Source from the content-addressed store, hash-verified

14
15
16class Search(SearchCommands):
17 class="st">"""
18 Create a client for talking to search.
19 It abstracts the API of the module and lets you just use the engine.
20 class="st">"""
21
22 class BatchIndexer:
23 class="st">"""
24 A batch indexer allows you to automatically batch
25 document indexing in pipelines, flushing it every N documents.
26 class="st">"""
27
28 def __init__(self, client, chunk_size=1000):
29 self.client = client
30 self.execute_command = client.execute_command
31 self._pipeline = client.pipeline(transaction=False, shard_hint=None)
32 self.total = 0
33 self.chunk_size = chunk_size
34 self.current_chunk = 0
35
36 def __del__(self):
37 if self.current_chunk:
38 self.commit()
39
40 def add_document(
41 self,
42 doc_id,
43 nosave=False,
44 score=1.0,
45 payload=None,
46 replace=False,
47 partial=False,
48 no_create=False,
49 **fields,
50 ):
51 class="st">"""
52 Add a document to the batch query
53 class="st">"""
54 self.client._add_document(
55 doc_id,
56 conn=self._pipeline,
57 nosave=nosave,
58 score=score,
59 payload=payload,
60 replace=replace,
61 partial=partial,
62 no_create=no_create,
63 **fields,
64 )
65 self.current_chunk += 1
66 self.total += 1
67 if self.current_chunk >= self.chunk_size:
68 self.commit()
69
70 def add_document_hash(self, doc_id, score=1.0, replace=False):
71 class="st">"""
72 Add a hash to the batch query
73 class="st">"""

Callers 3

query_agg.pyFile · 0.90
_make_searchFunction · 0.90
ftMethod · 0.85

Calls

no outgoing calls

Tested by 1

_make_searchFunction · 0.72