## Query Vectors `vectorize.indexes.query(strindex_name, IndexQueryParams**kwargs) -> IndexQueryResponse` **post** `/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query` Finds vectors closest to a given vector in an index. ### Parameters - `account_id: str` Identifier - `index_name: str` - `vector: Iterable[float]` The search vector that will be used to find the nearest neighbors. - `filter: Optional[object]` A metadata filter expression used to limit nearest neighbor results. - `return_metadata: Optional[Literal["none", "indexed", "all"]]` Whether to return no metadata, indexed metadata or all metadata associated with the closest vectors. - `"none"` - `"indexed"` - `"all"` - `return_values: Optional[bool]` Whether to return the values associated with the closest vectors. - `top_k: Optional[float]` The number of nearest neighbors to find. ### Returns - `class IndexQueryResponse: …` - `count: Optional[int]` Specifies the count of vectors returned by the search - `matches: Optional[List[Match]]` Array of vectors matched by the search - `id: Optional[str]` Identifier for a Vector - `metadata: Optional[object]` - `namespace: Optional[str]` - `score: Optional[float]` The score of the vector according to the index's distance metric - `values: Optional[List[float]]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.vectorize.indexes.query( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", vector=[0.5, 0.5, 0.5], ) print(response.count) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "count": 0, "matches": [ { "id": "some-vector-id-023e105f4ecef8ad9ca31a8372d0c353", "metadata": {}, "namespace": "namespace", "score": 0, "values": [ 0 ] } ] }, "success": true } ```