Closed lauradang closed 3 months ago
Answer generated by a 🤖
Hello,
Based on the error message you provided, it seems like there's a type mismatch between the vectors stored in your Elasticsearch index and the vectors you're trying to query with. The error message suggests that the system is trying to cast ScriptDocValues$Doubles
to VectorScriptDocValues$DenseVectorScriptDocValues
, which is causing the error.
This could be due to a few reasons:
The Elasticsearch index you're querying doesn't exist or is not properly set up. You can check this by using the client.indices.get(index=self.index_name)
method in the ElasticVectorSearch
class.
The query vector you're using to search the Elasticsearch index is not correctly formatted or is not compatible with the vectors stored in the index. The _default_knn_query
function in the ElasticVectorSearch
class is used to create the query for Elasticsearch. Make sure that the query_vector
argument passed to this function is a list of floats and that its dimension matches the dimension of the vectors stored in the Elasticsearch index.
The filter you're using in the _default_script_query
function is not correctly formatted. If a filter is provided, it should be a dictionary with one key-value pair. The key should be the name of a field in the Elasticsearch index and the value should be the value to filter by for that field.
If you're using the knn_search
or knn_hybrid_search
methods, ensure that the fields
parameter includes the page_content
field if source=False
. If source=False
and page_content
is not included in fields
, a ValueError
will be raised.
You can find more details about these methods in the ElasticVectorSearch class.
Also, there was a similar issue reported in the past: vectorstores error: "search_phase_execution_exceptionm" after using elastic search. This issue was resolved by a pull request: fix: elasticsearch. Unfortunately, I don't have the specific details of the changes made in this pull request, but it might be worth looking into.
Please let me know if this helps or if you need further assistance.
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
@agola11 @hwchase17 Could I get some help on this issue?
Hi @lauradang
Could you try using ElasticsearchStore instead? Its the new Vector store implementation for Elasticsearch. https://python.langchain.com/docs/integrations/vectorstores/elasticsearch#whats-new
Let me know how you get on.
Thanks!
Hey! Unfortunately the issue still persists with the new ElasticsearchStore implementation. Any new idea?
hey @DrSebastianK,
Could you share what version of Elasticsearch you're running on? Also how you have initialised ElasticsearchStore
, or if possible a example colab notebook of it not working for you?
Joe
Thanks for the fast reply. I am running it on v 8.9.2. The code: db = ElasticsearchStore( es_cloud_id="MY-ID", index_name="search-tmd", embedding=hf, es_user="elastic", es_password="mypassword", strategy=ElasticsearchStore.ApproxRetrievalStrategy( hybrid=True ) ) Query: db.similarity_search(query="textofmyquery", k=4)
does it work without hybrid? Could you provide the full stacktrace?
BadRequestError Traceback (most recent call last)
4 frames /usr/local/lib/python3.10/dist-packages/elasticsearch/_sync/client/_base.py in perform_request(self, method, path, params, headers, body) 318 pass 319 --> 320 raise HTTP_EXCEPTIONS.get(meta.status, ApiError)( 321 message=message, meta=meta, body=resp_body 322 )
BadRequestError: BadRequestError(400, 'search_phase_execution_exception', 'failed to create query: [knn] queries are only supported on [dense_vector] fields')
so theres an issue with the index that has been setup. The error is complaining that the field used to search vectors isn't a dense vector field.
Could you delete the search-tmd
and let langchain ElasticsearchStore to re-create & index documents?
Any new about this issue?
@disoardi search_phase_execution_exception
is a very general error. Could you give more details on your issue?
System Info
Langchain version:
0.0.254
Python version:3.10.2
Elasticsearch version:7.17.0
System Version: macOS 13.4 (22F66) Model Name: MacBook Pro Model Identifier: Mac14,10 Chip: Apple M2 Pro Total Number of Cores: 12 (8 performance and 4 efficiency) Memory: 32 GBWho can help?
@agola11 @hwchase17
Information
Related Components
Reproduction
run this using
python3 script.py
script.py
:Error traceback:
Expected behavior
I expect to ask questions and have answers provided back using the
langchain.chains.retrieval_qa.base.RetrievalQA
class. However, I am getting an error 400 when trying to query the LLM.Note: I do not get the same error when using ChromaDB or OpenSearch as the retriever.