Open duduxiao opened 1 month ago
Hey @duduxiao! I'm here to help you out with any bugs, questions, or contributions you might have. Let's work together to solve this issue.
To resolve the json_parse_exception
error when inserting data into the knn_vector
in the OpenSearchVectorStore
class, ensure that the data being inserted is correctly formatted as JSON. Specifically, check the structure of the operations
array in the addVectors
method. Here is the relevant code snippet:
const operations = vectors.flatMap((embedding, idx) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const document: Record<string, any> = [
{
index: {
_index: this.indexName,
_id: documentIds[idx],
},
},
{
[this.vectorFieldName]: embedding,
[this.textFieldName]: documents[idx].pageContent,
[this.metadataFieldName]: documents[idx].metadata,
},
];
// aoss does not support document id
if (this.isAoss) {
delete document[0].index?._id;
}
return document;
});
await this.client.bulk({ body: operations });
Ensure that the embedding
, pageContent
, and metadata
fields are correctly formatted and do not contain any invalid JSON structures. Additionally, verify that the knn_vector
field is correctly defined in the index mappings.
If the issue persists, you may need to add more detailed logging to identify the exact part of the data causing the json_parse_exception
[1].
To continue talking to Dosu, mention @dosu.
Checked other resources
Example Code
I use opensearch vector data; this is my script:
Error Message and Stack Trace (if applicable)
Above script no have error, so i debug opensearch.js then bulk return error:
Description
I find OpenSearchVectorStore.addVectors have a bug:
file opensearch.js
embedding modiify embedding[0] , It works!!
System Info
package.json
NodeJS version: