mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-29 19:18:53 +00:00
Add missing doc key to metadata field in AzureSearch Vectorstore (#13328)
- **Description:** Adds doc key to metadata field when adding document to Azure Search. - **Issue:** -, - **Dependencies:** -, - **Tag maintainer:** @eyurtsev, - **Twitter handle:** @finnless Right now the document key with the name FIELDS_ID is not included in the FIELDS_METADATA field, and therefore is not included in the Document returned from a query. This is really annoying if you want to be able to modify that item in the vectorstore. Other's thoughts on this are welcome.
This commit is contained in:
parent
e042e5df35
commit
b49104c2c9
@ -391,10 +391,21 @@ class AzureSearch(VectorStore):
|
||||
(
|
||||
Document(
|
||||
page_content=result.pop(FIELDS_CONTENT),
|
||||
metadata=json.loads(result[FIELDS_METADATA])
|
||||
metadata={
|
||||
**(
|
||||
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||
if FIELDS_ID in result
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
json.loads(result[FIELDS_METADATA])
|
||||
if FIELDS_METADATA in result
|
||||
else {
|
||||
k: v for k, v in result.items() if k != FIELDS_CONTENT_VECTOR
|
||||
k: v
|
||||
for k, v in result.items()
|
||||
if k != FIELDS_CONTENT_VECTOR
|
||||
}
|
||||
),
|
||||
},
|
||||
),
|
||||
float(result["@search.score"]),
|
||||
@ -452,10 +463,21 @@ class AzureSearch(VectorStore):
|
||||
(
|
||||
Document(
|
||||
page_content=result.pop(FIELDS_CONTENT),
|
||||
metadata=json.loads(result[FIELDS_METADATA])
|
||||
metadata={
|
||||
**(
|
||||
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||
if FIELDS_ID in result
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
json.loads(result[FIELDS_METADATA])
|
||||
if FIELDS_METADATA in result
|
||||
else {
|
||||
k: v for k, v in result.items() if k != FIELDS_CONTENT_VECTOR
|
||||
k: v
|
||||
for k, v in result.items()
|
||||
if k != FIELDS_CONTENT_VECTOR
|
||||
}
|
||||
),
|
||||
},
|
||||
),
|
||||
float(result["@search.score"]),
|
||||
@ -547,6 +569,11 @@ class AzureSearch(VectorStore):
|
||||
Document(
|
||||
page_content=result.pop(FIELDS_CONTENT),
|
||||
metadata={
|
||||
**(
|
||||
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||
if FIELDS_ID in result
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
json.loads(result[FIELDS_METADATA])
|
||||
if FIELDS_METADATA in result
|
||||
|
Loading…
Reference in New Issue
Block a user