Opensolr in LlamaIndex
llama-index-opensolr gives LlamaIndex an Opensolr vector store, an embedding model and a file reader. Your VectorStoreIndex, retrievers and query engines work unchanged, with the meaning vectors made on Opensolr servers.
Install and first query
pip install llama-index-opensolr
from llama_index.core import VectorStoreIndex, StorageContext, Document
from llama_index.vector_stores.opensolr import OpensolrVectorStore
from llama_index.embeddings.opensolr import OpensolrEmbedding
store = OpensolrVectorStore(index_name="my_index", email="you@example.com",
api_key="YOUR_OPENSOLR_API_KEY", create_if_missing=True)
embed_model = OpensolrEmbedding(index_name="my_index", email="you@example.com",
api_key="YOUR_OPENSOLR_API_KEY")
index = VectorStoreIndex.from_documents(
[Document(text="Hybrid search ranks words and meaning together")],
storage_context=StorageContext.from_defaults(vector_store=store),
embed_model=embed_model,
)
print(index.as_retriever(similarity_top_k=5).retrieve("keyword and meaning search"))
What you get
OpensolrVectorStore:VectorStoreQueryMode.HYBRIDwithalphafor the balance between meaning and words, and the standardMetadataFilters.OpensolrEmbedding: meaning vectors made on Opensolr servers.OpensolrReader: a file or a folder read into documents, a PDF page by page, scans and pictures through OCR.search_by_image(): search with a photo.ai_answer(): a grounded answer written from the best documents. No LLM key needed.- A keyword-only mode that uses none of your AI allowance.
Links
- LlamaIndex product page
- PyPI and GitHub, with the full guide in the README.
- No account yet? Use the public demo account.