WeaviateEx.Query.Rerank (WeaviateEx v0.7.4)

View Source

Reranking configuration for query results.

Reranking re-orders search results using a reranker model configured on the collection. The reranker scores results based on relevance to the query and returns a rerank_score in metadata.

Examples

# Rerank using a property
rerank = Rerank.new("content")

# Rerank with custom query
rerank = Rerank.new("content", query: "What is machine learning?")

# Use in query
Query.get("Article")
|> Query.near_text("machine learning")
|> Query.rerank(rerank)
|> Query.execute(client)

Summary

Functions

Create a new rerank configuration.

Convert rerank configuration to GraphQL format.

Convert rerank configuration to gRPC Rerank message.

Convert rerank configuration to map format (for gRPC).

Validate rerank configuration.

Types

t()

@type t() :: %WeaviateEx.Query.Rerank{prop: String.t(), query: String.t() | nil}

Functions

new(prop, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: t()

Create a new rerank configuration.

Parameters

  • prop - The property to use for reranking (e.g., "content", "description")
  • opts - Options:
    • :query - Optional query string for reranking. If not provided, the original search query is used.

Examples

# Basic rerank on a property
Rerank.new("content")

# Rerank with custom query
Rerank.new("content", query: "What is deep learning?")

# Rerank on description field
Rerank.new("description", query: "AI applications")

to_graphql(rerank)

@spec to_graphql(t()) :: String.t()

Convert rerank configuration to GraphQL format.

Examples

rerank = Rerank.new("content", query: "deep learning")
Rerank.to_graphql(rerank)
# => "{property: "content", query: "deep learning"}"

to_grpc(rerank)

@spec to_grpc(t()) :: struct()

Convert rerank configuration to gRPC Rerank message.

Examples

rerank = Rerank.new("content", query: "deep learning")
Rerank.to_grpc(rerank)
# => %Weaviate.V1.Rerank{property: "content", query: "deep learning"}

to_map(rerank)

@spec to_map(t()) :: map()

Convert rerank configuration to map format (for gRPC).

Examples

rerank = Rerank.new("content", query: "deep learning")
Rerank.to_map(rerank)
# => %{property: "content", query: "deep learning"}

valid?(arg1)

@spec valid?(t()) :: boolean()

Validate rerank configuration.

Examples

iex> Rerank.valid?(Rerank.new("content"))
true

iex> Rerank.valid?(%Rerank{prop: nil})
false