MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / main

Function main

examples/couchbase/vector_search.py:136–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134
135
136def main():
137 auth = PasswordAuthenticator('Administrator', 'password')
138 opts = ClusterOptions(auth)
139 cluster = Cluster.connect('couchbase://localhost', opts)
140 bucket = cluster.bucket('default')
141 collection = bucket.default_collection()
142
143 # NOTE: validate paths (see note on line 17) if going to use setup/teardown functionality
144 keys = setup(cluster, collection)
145 vector = load_test_vector()
146
147 search_req = search.SearchRequest.create(search.MatchAllQuery()).with_vector_search(
148 VectorSearch.from_vector_query(VectorQuery('vector_field', vector)))
149 search_iter = cluster.search(TEST_INDEX_NAME, search_req, SearchOptions(limit=2))
150 for row in search_iter.rows():
151 print(f'row: {row}')
152
153 print(f'Metatdata: {search_iter.metadata()}')
154
155 # NOTE: only use in conjunction w/ setup() method
156 teardown(cluster, collection, keys)
157
158
159if __name__ == '__main__':

Callers 1

vector_search.pyFile · 0.70

Calls 15

ClusterOptionsClass · 0.90
VectorQueryClass · 0.90
SearchOptionsClass · 0.90
with_vector_searchMethod · 0.80
from_vector_queryMethod · 0.80
setupFunction · 0.70
load_test_vectorFunction · 0.70
teardownFunction · 0.70
connectMethod · 0.45
bucketMethod · 0.45
default_collectionMethod · 0.45

Tested by

no test coverage detected