mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-03 03:38:06 +00:00
BUGFIX: Support for elastic indices that don't return 'metadata' in '_source' (#13903)
Description: Some Elastic indexes do not return a 'metadata' field in '_source'. However, prior to this PR, the code assumed there always is a 'metadata' field. This PR adds support for cases where the field is missing by adding it manually. Issue: #13869
This commit is contained in:
parent
c156d0281a
commit
ba62ff89cc
@ -798,6 +798,8 @@ class ElasticsearchStore(VectorStore):
|
||||
"metadata",
|
||||
self.query_field,
|
||||
]:
|
||||
if "metadata" not in hit["_source"]:
|
||||
hit["_source"]["metadata"] = {}
|
||||
hit["_source"]["metadata"][field] = hit["_source"][field]
|
||||
|
||||
docs_and_scores.append(
|
||||
|
Loading…
Reference in New Issue
Block a user