You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I use some of the similarity_search* methods i can not retrieve all fields of my Elasticsearch Index. The custom doc_builder method has no effect because the fields i would like to return are already not in the hits that get returned by the underlying search call.
I investigated and found out that the fields parameter of the underlying search method is not correctly treated.
This is for example one of the places where this happens:
I tested it out, if you copy all the content of the similarity_search* method and provide the field list and also specify a custom doc_builder you can retrieve other fields then just your text_field and metadata.
Then one can simply specify the fields and the documents come out with all fields. Also I think a this point some how the id of the elements should also be specified to be returned.
Now this is the implementation:
The text was updated successfully, but these errors were encountered:
krauhen
changed the title
Elastisearch 'fields' parameter not usable
Elastisearch 'fields' parameter not usable in similarity_search* methods
Jan 30, 2025
Problem
If I use some of the similarity_search* methods i can not retrieve all fields of my Elasticsearch Index. The custom doc_builder method has no effect because the fields i would like to return are already not in the hits that get returned by the underlying search call.
I investigated and found out that the fields parameter of the underlying search method is not correctly treated.
This is for example one of the places where this happens:
langchain-elastic/libs/elasticsearch/langchain_elasticsearch/_sync/vectorstores.py
Line 567 in 03da5e1
I tested it out, if you copy all the content of the similarity_search* method and provide the field list and also specify a custom doc_builder you can retrieve other fields then just your text_field and metadata.
Example code
Hot fix
Soution/Fix
So i would suggest to update this line:
langchain-elastic/libs/elasticsearch/langchain_elasticsearch/_sync/vectorstores.py
Line 567 in 03da5e1
to this:
in every similarity_search* occurence in this file.
If you see that the same I can create the PR with the fix.
EDIT
I thought about it and i think in general there should be a standard document builder that looks more like this:
Then one can simply specify the fields and the documents come out with all fields. Also I think a this point some how the id of the elements should also be specified to be returned.
Now this is the implementation:
langchain-elastic/libs/elasticsearch/langchain_elasticsearch/_utilities.py
Line 72 in 03da5e1
The text was updated successfully, but these errors were encountered: