mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-03 21:54:04 +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(
|
Document(
|
||||||
page_content=result.pop(FIELDS_CONTENT),
|
page_content=result.pop(FIELDS_CONTENT),
|
||||||
metadata=json.loads(result[FIELDS_METADATA])
|
metadata={
|
||||||
if FIELDS_METADATA in result
|
**(
|
||||||
else {
|
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||||
k: v for k, v in result.items() if k != FIELDS_CONTENT_VECTOR
|
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
|
||||||
|
}
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
float(result["@search.score"]),
|
float(result["@search.score"]),
|
||||||
@ -452,10 +463,21 @@ class AzureSearch(VectorStore):
|
|||||||
(
|
(
|
||||||
Document(
|
Document(
|
||||||
page_content=result.pop(FIELDS_CONTENT),
|
page_content=result.pop(FIELDS_CONTENT),
|
||||||
metadata=json.loads(result[FIELDS_METADATA])
|
metadata={
|
||||||
if FIELDS_METADATA in result
|
**(
|
||||||
else {
|
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||||
k: v for k, v in result.items() if k != FIELDS_CONTENT_VECTOR
|
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
|
||||||
|
}
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
float(result["@search.score"]),
|
float(result["@search.score"]),
|
||||||
@ -547,6 +569,11 @@ class AzureSearch(VectorStore):
|
|||||||
Document(
|
Document(
|
||||||
page_content=result.pop(FIELDS_CONTENT),
|
page_content=result.pop(FIELDS_CONTENT),
|
||||||
metadata={
|
metadata={
|
||||||
|
**(
|
||||||
|
{FIELDS_ID: result.pop(FIELDS_ID)}
|
||||||
|
if FIELDS_ID in result
|
||||||
|
else {}
|
||||||
|
),
|
||||||
**(
|
**(
|
||||||
json.loads(result[FIELDS_METADATA])
|
json.loads(result[FIELDS_METADATA])
|
||||||
if FIELDS_METADATA in result
|
if FIELDS_METADATA in result
|
||||||
|
Loading…
Reference in New Issue
Block a user