Searches records using text queries that get automatically embedded, with optional reranking. This is only available for indexes created with `create_index_for_model()`.
Usage
records_search(
index,
query,
namespace = "",
top_k = 10,
filter = NULL,
fields = NULL,
rerank = NULL,
tidy = TRUE
)Arguments
- index
Name of the index (must have integrated embedding model)
- query
The search input. Can be: - A character string (text query to embed) - A numeric vector (raw embedding vector) - A list with `id` field to search by record ID
- namespace
Namespace to search in (default: "")
- top_k
Number of results to return (default: 10)
- filter
Metadata filter (list)
- fields
Character vector of metadata fields to return (default: all)
- rerank
Optional reranking configuration. A list with: - model: Reranking model name (e.g., "pinecone-rerank-v0") - top_n: Number of results after reranking - rank_fields: Fields to use for reranking
- tidy
Whether to return tidy tibble format (default: TRUE)
Value
List with http response, content (search results), and status_code. When tidy = TRUE, content is a tibble with columns for id, score, and fields.
Details
The index must be created with `create_index_for_model()`. Text queries are automatically embedded using the index's configured model.
Reranking improves result quality by re-scoring results based on semantic relevance to the query.
Examples
if (FALSE) { # \dontrun{
# Simple text search
results <- records_search(
index = "my-index",
query = "What does the fox do?",
top_k = 5
)
# Search with metadata filter
results <- records_search(
index = "my-index",
query = "machine learning applications",
filter = list(category = list(`$eq` = "tech")),
top_k = 10
)
# Search with reranking for better results
results <- records_search(
index = "my-index",
query = "How does AI impact healthcare?",
top_k = 100,
rerank = list(
model = "pinecone-rerank-v0",
top_n = 10,
rank_fields = c("chunk_text")
)
)
# Search by vector
results <- records_search(
index = "my-index",
query = my_embedding_vector,
top_k = 5
)
# Search by record ID (find similar)
results <- records_search(
index = "my-index",
query = list(id = "rec1"),
top_k = 5
)
} # }