ResultView¶
ResultView is the common return type for search, query, head, tail, range, and
data retrieval APIs.
Result shapes¶
Search results contain IDs and distances:
result = collection.search(query, k=3, return_fields=True)
print(result.ids) # np.ndarray[int64]
print(result.distances) # np.ndarray[float32]
print(result.fields) # list[dict]
Data results contain vectors:
result = collection.query_vectors(filter_ids=[1, 2, 3])
print(result.ids)
print(result.vectors) # np.ndarray[float32], shape (n, dim)
print(result.fields)
Query results contain IDs and optional fields:
The main result types are:
| Result type | Produced by | Main attributes |
|---|---|---|
search |
search, batch_search, search_range, text_search, search_sparse, hybrid_search |
ids, distances, optional fields |
query |
query |
ids, optional fields |
data |
query_vectors, head, tail, remote read_by_only_id |
vectors, ids, fields |
distances may be lower-is-better distances or higher-is-better scores
depending on the metric. See the indexing and search tutorials for metric
semantics.
Tuple unpacking¶
Search results unpack as (ids, distances, fields):
Data results unpack as (vectors, ids, fields):
Prefer attributes when clarity matters.
Row iteration¶
ResultView is not a row iterator. Convert to rows first:
to_list() returns dictionaries such as:
Conversion helpers¶
Typical use:
Use to_numpy() for numerical post-processing and to_list() for application
responses or debug prints.
Optional conversions:
result.to_pandas() # requires pandas
result.to_polars() # requires polars
result.to_arrow() # requires pyarrow
Indexing by component¶
Use string keys to access components:
Integer row indexing is intentionally not the main access path. Use
result.to_list()[0] when you need the first row as a dict.
Empty results¶
Empty results are still valid ResultView objects:
result = collection.query(where="lang = 'missing'")
print(len(result)) # 0
print(bool(result)) # False
print(result.ids) # empty int64 array
print(result.to_list()) # []
This lets application code handle "no match" without special exception paths.