Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion libs/langchain-community/src/vectorstores/milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,22 @@ export class Milvus extends VectorStore {
});
desc.schema.fields.forEach((field) => {
this.fields.push(field.name);
// Only remove autoID fields from this.fields if we're using autoId mode
// Remove autoID fields from this.fields if we're using autoId mode
// When autoId is false, we need to include the primary field for upsert operations
if (field.autoID && this.autoId) {
const index = this.fields.indexOf(field.name);
if (index !== -1) {
this.fields.splice(index, 1);
}
}
// Remove isFunctionOutput fields from this.fields if this field is calculated on server side
// When isFunctionOutput is false, we need to include this field for upsert operations
if (field.is_function_output) {
const index = this.fields.indexOf(field.name);
if (index !== -1) {
this.fields.splice(index, 1);
}
}
if (field.is_primary_key) {
this.primaryField = field.name;
}
Expand Down
11 changes: 11 additions & 0 deletions libs/langchain-community/src/vectorstores/tests/milvus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,38 @@ const fields = [
{
name: "id",
is_primary_key: true,
is_function_output: false,
autoID: true,
data_type: 21,
},
{
name: "text",
is_primary_key: false,
is_function_output: false,
autoID: false,
data_type: 21,
},
{
name: "vector",
is_primary_key: false,
is_function_output: false,
autoID: false,
data_type: 101,
},
{
name: "custom_field",
is_primary_key: false,
is_function_output: false,
autoID: false,
data_type: 21,
},
{
name: "vector_calculated",
is_primary_key: false,
is_function_output: true,
autoID: false,
data_type: 104,
},
];

// Mock successful responses
Expand Down