ElasticsearchTranslator generating invalid queries for Date type #17042
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
🔌: elasticsearch
Primarily related to elastic/elasticsearch integrations
Ɑ: vector store
Related to vector store module
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
File "/usr/local/lib/python3.10/dist-packages/langchain_core/retrievers.py", line 121, in invoke
return self.get_relevant_documents(
File "/usr/local/lib/python3.10/dist-packages/langchain_core/retrievers.py", line 224, in get_relevant_documents
raise e
File "/usr/local/lib/python3.10/dist-packages/langchain_core/retrievers.py", line 217, in get_relevant_documents
result = self._get_relevant_documents(
File "/usr/local/lib/python3.10/dist-packages/langchain/retrievers/self_query/base.py", line 171, in _get_relevant_documents
docs = self._get_docs_with_query(new_query, search_kwargs)
File "/usr/local/lib/python3.10/dist-packages/langchain/retrievers/self_query/base.py", line 145, in _get_docs_with_query
docs = self.vectorstore.search(query, self.search_type, **search_kwargs)
File "/usr/local/lib/python3.10/dist-packages/langchain_core/vectorstores.py", line 139, in search
return self.similarity_search(query, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/elasticsearch.py", line 632, in similarity_search
results = self._search(
File "/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/elasticsearch.py", line 815, in _search
response = self.client.search(
File "/usr/local/lib/python3.10/dist-packages/elasticsearch/_sync/client/utils.py", line 402, in wrapped
return api(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/elasticsearch/_sync/client/init.py", line 3733, in search
return self.perform_request( # type: ignore[return-value]
File "/usr/local/lib/python3.10/dist-packages/elasticsearch/_sync/client/_base.py", line 320, in perform_request
raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.BadRequestError: BadRequestError(400, 'x_content_parse_exception', '[range] query does not support [date]')
Description
The ElasticsearchTranslator should not put comparison value in the field directly since it cause a syntax error in the query, instead if it's a date it should put the value of the date (just like in the issue #16022)
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
The text was updated successfully, but these errors were encountered: