langchain-opensolr
LangChain integration for Opensolr — managed Apache Solr with server-side embeddings and native hybrid (BM25 + kNN) search.
No local embedding model. No third-party embedding API key. One set of credentials, and the vectors are computed on Opensolr's GPU infrastructure (multilingual E5-large-instruct, 1024 dimensions, cosine).
pip install langchain-opensolr
The whole tutorial
from langchain_opensolr import OpensolrVectorStore
vs = OpensolrVectorStore(
index="mysite__dense", # vector-enabled Opensolr index
email="you@example.com",
api_key="YOUR_OPENSOLR_API_KEY",
create_if_missing=True, # provisions the index on first use
)
vs.add_texts(
["Hybrid search fuses BM25 with vector similarity",
"Cats sleep sixteen hours a day"],
metadatas=[{"category": "search"}, {"category": "animals"}],
)
docs = vs.similarity_search("how do lexical and semantic search combine?", k=1)
print(docs[0].page_content)
That's it — no embedding model was configured, because embedding happens on the server at both index and query time.
Hybrid search
Pure vector search fails on exact identifiers; pure BM25 fails on meaning.
Opensolr's {!hybrid} query parser fuses both scores per document:
docs = vs.similarity_search(
"affordable restaurants",
k=5,
hybrid=True,
mode="union", # union | keywords_required | meaning_required | intersection
alpha=0.5, # 0 = all semantic … 1 = all lexical
)
Metadata filters
vs.similarity_search("search engines", k=5, filter={"category": "search"})
vs.similarity_search("anything", k=5, filter='meta_rank:[2 TO *]') # raw Solr fq
Metadata round-trips losslessly (stored as JSON alongside filterable
meta_* fields).
As a retriever, in any chain
retriever = vs.as_retriever(search_kwargs={"k": 5, "hybrid": True})
Standalone embeddings
Use Opensolr's embedding endpoint with any other LangChain component:
from langchain_opensolr import OpensolrEmbeddings
emb = OpensolrEmbeddings(email="you@example.com", api_key="...", index="mysite__dense")
emb.embed_query("budget-friendly dining") # -> 1024 floats
Notes
- Vector-enabled indexes run on Opensolr's Solr 9.x environments — locations
us(Chicago),de(Germany),fi(Finland). Passlocation=to choose. - A free Opensolr account (15-day trial, no card) includes an AI quota that comfortably covers this README end to end: opensolr.com.
- Full platform docs: AI & Vector Search.
Development
pip install -e . pytest
pytest tests/unit_tests
OPENSOLR_EMAIL=... OPENSOLR_API_KEY=... OPENSOLR_INDEX=... pytest tests/integration_tests
MIT license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_opensolr-0.1.0.tar.gz.
File metadata
- Download URL: langchain_opensolr-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a36131aadb84bb0eba02c87c9197f4b8925a550c841b5460ae7fc0c6d2197bc2
|
|
| MD5 |
5cce92ae48c4c9ea88179a8cc31d2bbb
|
|
| BLAKE2b-256 |
4d495f83744fd0e8c85602de4d1207c96be1fae2ff79148964f337a57aaf3b10
|
File details
Details for the file langchain_opensolr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_opensolr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f1b74482af6f7ac3835a945b1f878207ac78c91fed19d5f3b29b4d2ba0e889c
|
|
| MD5 |
71b57c1533e73cb9fc96474f39bb2e13
|
|
| BLAKE2b-256 |
0c546ea668e2a775fca6b374ae25a0f9f9128fc3d7e2949fc68667802590a36d
|