QueryResultItem

Describes one vector search result.

For the list of response object types, see Response Objects.

Use QueryResultItem to inspect the identifier, metadata, optional vector, and distance score for a single search result.

Attributes

Attribute Type Description
id str or None Vector record identifier.
metadata dict[str, Any] or None Metadata associated with the matched vector.
vector list[int or float] or None Vector values returned with the search result, when requested.
distance int or float or None Distance or similarity score for the search result.

Methods

Method Return Type Description
model_dump() dict[str, Any] Returns a Pydantic dictionary representation of the object.
model_dump_json() str Returns a Pydantic JSON string representation of the object.
to_dict() dict[str, Any] Returns a dictionary representation compatible with earlier SDK response handling.
to_json() str Returns a JSON string representation compatible with earlier SDK response handling.
to_str() str Returns a readable string representation compatible with earlier SDK response handling.

Iterate Attributes

Use the item serialization helper to iterate every public attribute on the search result item.

response = client.query(
    table_name="product_vectors",
    query_by={"vector": [0.12, 0.45, 0.32]},
    top_k=3,
)

for item in response.items:
    item_payload = item.to_dict()
    for attribute, value in item_payload.items():
        print(attribute, value)

Sample Response

{
  "id": "prod_001",
  "metadata": {
    "name": "Trail running shoes",
    "category": "footwear"
  },
  "vector": [0.12, 0.45, 0.32],
  "distance": 0.00393
}

Contained By

Contained by: QueryResponse.