Milvex.SearchResult
(milvex v0.10.2)
Copy Markdown
Parser for Milvus search results.
Converts the flat SearchResultData format from Milvus into structured results grouped by query.
Examples
# Parse from proto
{:ok, result} = SearchResult.from_proto(search_results)
# Access results
result.num_queries # Number of queries
result.top_k # Top-K used
result.collection_name # Collection searched
# Hits GROUPED BY QUERY - result.hits is list of lists
result.hits # [[query1_hits], [query2_hits], ...]
query1_hits = Enum.at(result.hits, 0)
# Each hit in a query group
hit.id # Primary key
hit.score # Similarity score
hit.distance # Raw distance (optional)
hit.fields # Map of output field values
Summary
Functions
Checks if the result is empty.
Parses a SearchResults proto into a SearchResult struct.
Returns the hits for a specific query.
Returns the top hit for each query.
Returns the total number of hits across all queries.
Types
@type hits_list() :: [[Milvex.SearchResult.Hit.t()]]
@type hits_map() :: %{required(atom()) => [Milvex.SearchResult.Hit.t()]}
@type t() :: %Milvex.SearchResult{ collection_name: String.t(), hits: hits_list() | hits_map(), num_queries: non_neg_integer(), top_k: non_neg_integer() }
Functions
Checks if the result is empty.
@spec from_proto(Milvex.Milvus.Proto.Milvus.SearchResults.t()) :: t()
Parses a SearchResults proto into a SearchResult struct.
Converts flat result arrays into hits grouped by query.
Parameters
proto- The SearchResults protobuf struct
@spec get_query_hits(t(), non_neg_integer() | atom()) :: [Milvex.SearchResult.Hit.t()]
Returns the hits for a specific query.
For list-based results, pass a 0-indexed integer. For keyed results, pass the atom key used in the search.
@spec top_hits(t()) :: [Milvex.SearchResult.Hit.t() | nil] | %{required(atom()) => Milvex.SearchResult.Hit.t() | nil}
Returns the top hit for each query.
For list-based results, returns a list of top hits. For keyed results, returns a map with the same keys.
@spec total_hits(t()) :: non_neg_integer()
Returns the total number of hits across all queries.