RAG with Elasticsearch Backend
Source:vignettes/elasticsearch-backend.Rmd
elasticsearch-backend.RmdThis vignette shows how to query an Elasticsearch vector index from
RAGFlowChainR.
2) Configure Elasticsearch target
# Optional if your cluster requires API key auth.
# Provide either raw key or full "ApiKey <token>" string.
Sys.setenv(ELASTIC_API_KEY = "your-elastic-api-key")
# Format: "https://host:9200|index_name|vector_field"
# vector_field is optional; default is "embedding"
elastic_target <- "https://your-elastic-host:9200|vectors|embedding"3) Create the RAG chain
my_llm <- function(prompt) {
"Mock answer from LLM."
}
rag_chain <- create_rag_chain(
llm = my_llm,
vector_database_directory = elastic_target,
method = "Elasticsearch",
embedding_function = embed_openai(model = "text-embedding-3-small"),
embedding_dim = 1536,
use_web_search = FALSE
)