()
| 134 | |
| 135 | |
| 136 | def 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 | |
| 159 | if __name__ == '__main__': |
no test coverage detected