()
| 147 | |
| 148 | @defer.inlineCallbacks |
| 149 | def main(): |
| 150 | auth = PasswordAuthenticator('Administrator', 'password') |
| 151 | opts = ClusterOptions(auth) |
| 152 | cluster = TxCluster('couchbase://localhost', opts) |
| 153 | yield cluster.on_connect() |
| 154 | bucket = cluster.bucket('default') |
| 155 | yield bucket.on_connect() |
| 156 | collection = bucket.default_collection() |
| 157 | |
| 158 | # NOTE: validate paths (see note on line 22) if going to use setup/teardown functionality |
| 159 | keys = yield setup(cluster, collection) |
| 160 | vector = load_test_vector() |
| 161 | |
| 162 | search_req = search.SearchRequest.create(search.MatchAllQuery()).with_vector_search( |
| 163 | VectorSearch.from_vector_query(VectorQuery('vector_field', vector))) |
| 164 | search_iter = yield cluster.search(TEST_INDEX_NAME, search_req, SearchOptions(limit=2)) |
| 165 | for row in search_iter.rows(): |
| 166 | print(f'row: {row}') |
| 167 | |
| 168 | print(f'Metatdata: {search_iter.metadata()}') |
| 169 | |
| 170 | # NOTE: only use in conjunction w/ setup() method |
| 171 | yield teardown(cluster, collection, keys) |
| 172 | reactor.stop() |
| 173 | |
| 174 | |
| 175 | if __name__ == "__main__": |
no test coverage detected