Runs ragnar_retrieve_vss()
and ragnar_retrieve_bm25()
and get the distinct
documents.
Arguments
- store
A
RagnarStore
object returned byragnar_store_connect()
orragnar_store_create()
.- text
Character. Query string to match.
- top_k
Integer, the number of entries to retrieve using per method.
- ...
Forwarded to
ragnar_retrieve_vss()
See also
Other ragnar_retrieve:
ragnar_retrieve()
,
ragnar_retrieve_bm25()
,
ragnar_retrieve_vss()
Examples
if (FALSE) { # (rlang::is_installed("dbplyr") && nzchar(Sys.getenv("OPENAI_API_KEY")))
## Build a small store with categories
store <- ragnar_store_create(
embed = \(x) ragnar::embed_openai(x, model = "text-embedding-3-small"),
extra_cols = data.frame(category = character()),
version = 1 # store text chunks directly
)
ragnar_store_insert(
store,
data.frame(
category = c(rep("pets", 3), rep("dessert", 3)),
text = c("playful puppy", "sleepy kitten", "curious hamster",
"chocolate cake", "strawberry tart", "vanilla ice cream")
)
)
ragnar_store_build_index(store)
# Top 3 chunks without filtering
ragnar_retrieve(store, "sweet")
# Combine filter with similarity search
ragnar_retrieve(store, "sweet", filter = category == "dessert")
}