Eurelis-Langchain-SolR-VectorStore
This library allows to use a Solr based vector store with the python version of LangChain
Usage
This library assume you already have a running Solr instance with a configured dense vector field
<fieldType name="knn_vector" class="solr.DenseVectorField" vectorDimension="768" similarityFunction="euclidean"/>
<field name="vector" type="knn_vector" indexed="true" stored="true"/>
Be sure to set a vectorDimension value corresponding to what yor embeddings model provide.
from langchain.embeddings import HuggingFaceEmbeddings
from eurelis_langchain_solr_vectorstore import Solr
embeddings = HuggingFaceEmbeddings() # you are free to use any embeddings method allowed by langchain
vector_store = Solr(embeddings) # with default core configuration
You can also specify data about the solr instance and core to use:
vector_store = Solr(embeddings, core_kwargs={
'page_content_field': 'text_t', # field containing the text content
'vector_field': 'vector', # field containing the embeddings of the text content
'core_name': 'langchain', # core name
'url_base': 'http://localhost:8983/solr', # base url to access solr
'query_handler': 'select', # handler to use to query solr
'update_handler': 'update', # update handler for solr
'metadata_fields': [] # additional solr fields to consider as metadata, ie ['id']
}) # with custom default core configuration
In the code above you have both the allowed core arguments and the default value.
Metadata
The Solr based vector store also supports storing and filtering on metadata.
Metadata are mapped into Solr using the following convention: metadata_{key}_{type} with key being the original metadata key, and type is automatically inferred as:
- i for integer fields
- d for float fields
- s for string fields
- b for boolean fields
The vector_search method take an optional where param expecting a dict:
- dict item key: base name of a metadata field
- dict item value: value expected in the metadata field
Example using the vector store as a retriever:
retriever = vector_store.as_retriever()
Example adding filter instructions to the retriever
retriever = vector_store.as_retriever(search_kwargs={'filter': {'language': 'en', 'year': 2000}})
Docker
A docker compose file is present in the etc/docker folder, use it with
docker compose up -d
To launch a solr instance with a core named langchain and a 'vector' field with 768 dimensions.
Metadata
Release files for eurelis-langchain-solr-vectorstore 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| eurelis_langchain_solr_vectorstore-0.0.3.tar.gz | 11.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eurelis_langchain_solr_vectorstore-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / eurelis_langchain_solr_vectorstore-0.0.3.tar.gz
| Download URL | eurelis_langchain_solr_vectorstore-0.0.3.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a39888af6949630ff50f915b47e3b232fcdc0f22573dbb06846c8d9a1264517
|
|
BLAKE2b-256 checksum How to use checksums |
5e4cf4c77cca0a49bd89809c93b096cfbd3d80fb7473c5598805c6f0961c85dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.3
|
Release files / eurelis_langchain_solr_vectorstore-0.0.3-py3-none-any.whl
| Download URL | eurelis_langchain_solr_vectorstore-0.0.3-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e6afad2cecfb29ccc2d85aedc2bb0e0f98fe86402d0817e557960721b484a71
|
|
BLAKE2b-256 checksum How to use checksums |
61d9c16fd791a6420155618e15eeabce968e1d26ab4f3243b282e700e9c1079a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.3
|
Security for eurelis-langchain-solr-vectorstore 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.