MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / check_doc_count

Function check_doc_count

examples/couchbase/vector_search.py:36–55  ·  view source on GitHub ↗
(sixm,
                    idx_name: str,
                    min_count: int,
                    retries: Optional[int] = 20,
                    delay: Optional[int] = 30
                    )

Source from the content-addressed store, hash-verified

34
35
36def check_doc_count(sixm,
37 idx_name: str,
38 min_count: int,
39 retries: Optional[int] = 20,
40 delay: Optional[int] = 30
41 ) -> bool:
42
43 indexed_docs = 0
44 no_docs_cutoff = 300
45 for i in range(retries):
46 # if no docs after waiting for a period of time, exit
47 if indexed_docs == 0 and i * delay >= no_docs_cutoff:
48 return 0
49 indexed_docs = sixm.get_indexed_documents_count(idx_name)
50 if indexed_docs >= min_count:
51 break
52 print(f'Found {indexed_docs} indexed docs, waiting a bit...')
53 sleep(delay)
54
55 return indexed_docs
56
57
58def load_search_idx(cluster: Cluster) -> None:

Callers 1

load_search_idxFunction · 0.70

Calls 1

Tested by

no test coverage detected