This category relates to the Enterprise Search set of products - App Search, Site Search and Workplace Search.
If your question relates to core Elasticsearch functionality, please head over to the Elasticsearch category for assistance.
I am using in python the libraries langchain_elasticsearch to implement a MultiQueryRetriever. from the code seen below.
from langchain_elasticsearch import ElasticsearchStore
from langchain.retrievers.multi_query import MultiQueryRetriever
vectorstore = ElasticsearchStore(
embedding=embeddings,
vector_query_field = "query_embeddings",
query_field = "query_field",
index_name="index_with_embeddings",
es_connection=es_client
)
retriever = MultiQueryRetriever( retriever=vectorstore.as_retriever(), llm_chain=llm_chain, parser_key="lines")
unique_docs = retriever.get_relevant_documents(query='here is the question?')
The mapping of the index is the following:
"index_with_embeddings": {
"mappings": {
"dynamic": "strict",
"properties": {
"CreateTimeStamp": {
"type": "date"
},
"query_embeddings": {
"type": "dense_vector",
"dims": 1536,
"index": true,
"similarity": "cosine"
},
"query_field": {
"type": "text"
},
"Sequence": {
"type": "integer"
},
"Field_add1": {
"type": "text"
},
"Field_add2": {
"type": "text"
}
}
}
}
The error I got in python is the following:
[Lib\site-packages\langchain\retrievers\multi_query.py:175](file://.venv/Lib/site-packages/langchain/retrievers/multi_query.py:175),
in MultiQueryRetriever._get_relevant_documents(self, query, run_manager)
[173](file://.venv/Lib/site-packages/langchain/retrievers/multi_query.py:173)
if self.include_original:
[807](file://.venv/Lib/site-packages/langchain_elasticsearch/vectorstores.py:807)
page_content=hit["_source"].get(self.query_field, ""),
[808](file://.venv/Lib/site-packages/langchain_elasticsearch/vectorstores.py:808)
metadata=hit["_source"]["metadata"],
Does anybody know how this problem can be fixed to use an existing index with the definition mentioned above?
The current notebooks in github are precarious and they don't give details about existing indexes. (here is the link ) elasticsearch-labs/notebooks/langchain at main · elastic/elasticsearch-labs · GitHub
Do the indexes must follow the schema of the "langchain schema document"? Is there any way to use an existing index that does have a different structure?