# `Milvex.SearchResult`

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

# `hits_list`

```elixir
@type hits_list() :: [[Milvex.SearchResult.Hit.t()]]
```

# `hits_map`

```elixir
@type hits_map() :: %{required(atom()) =&gt; [Milvex.SearchResult.Hit.t()]}
```

# `t`

```elixir
@type t() :: %Milvex.SearchResult{
  collection_name: String.t(),
  hits: hits_list() | hits_map(),
  num_queries: non_neg_integer(),
  top_k: non_neg_integer()
}
```

# `empty?`

```elixir
@spec empty?(t()) :: boolean()
```

Checks if the result is empty.

# `from_proto`

```elixir
@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

# `get_query_hits`

```elixir
@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.

# `top_hits`

```elixir
@spec top_hits(t()) ::
  [Milvex.SearchResult.Hit.t() | nil]
  | %{required(atom()) =&gt; 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.

# `total_hits`

```elixir
@spec total_hits(t()) :: non_neg_integer()
```

Returns the total number of hits across all queries.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
