@vectorstores/milvus 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -137,12 +137,14 @@ class MilvusVectorStore extends core.BaseVectorStore {
137
137
  }
138
138
  return result.IDs.str_id.data.map((s)=>String(s));
139
139
  }
140
- async delete(refDocId, deleteOptions) {
140
+ /**
141
+ * Deletes all nodes from the collection that belong to the given document.
142
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
143
+ * @param deleteOptions Additional delete options.
144
+ */ async delete(refDocId, deleteOptions) {
141
145
  await this.ensureCollection();
142
146
  await this.milvusClient.delete({
143
- ids: [
144
- refDocId
145
- ],
147
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
146
148
  collection_name: this.collectionName,
147
149
  ...deleteOptions
148
150
  });
@@ -179,6 +181,18 @@ class MilvusVectorStore extends core.BaseVectorStore {
179
181
  async persist() {
180
182
  // no need to do anything
181
183
  }
184
+ async exists(refDocId) {
185
+ await this.ensureCollection();
186
+ const result = await this.milvusClient.query({
187
+ collection_name: this.collectionName,
188
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
189
+ output_fields: [
190
+ this.idKey
191
+ ],
192
+ limit: 1
193
+ });
194
+ return result.data.length > 0;
195
+ }
182
196
  }
183
197
 
184
198
  exports.MilvusVectorStore = MilvusVectorStore;
package/dist/index.d.cts CHANGED
@@ -33,10 +33,16 @@ declare class MilvusVectorStore extends BaseVectorStore {
33
33
  private createCollection;
34
34
  private ensureCollection;
35
35
  add(nodes: BaseNode<Metadata>[]): Promise<string[]>;
36
+ /**
37
+ * Deletes all nodes from the collection that belong to the given document.
38
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
39
+ * @param deleteOptions Additional delete options.
40
+ */
36
41
  delete(refDocId: string, deleteOptions?: Omit<DeleteReq, "ids">): Promise<void>;
37
42
  toMilvusFilter(filters?: MetadataFilters): string | undefined;
38
43
  query(query: VectorStoreQuery, _options?: object): Promise<VectorStoreQueryResult>;
39
44
  persist(): Promise<void>;
45
+ exists(refDocId: string): Promise<boolean>;
40
46
  }
41
47
 
42
48
  export { MilvusVectorStore };
package/dist/index.d.ts CHANGED
@@ -33,10 +33,16 @@ declare class MilvusVectorStore extends BaseVectorStore {
33
33
  private createCollection;
34
34
  private ensureCollection;
35
35
  add(nodes: BaseNode<Metadata>[]): Promise<string[]>;
36
+ /**
37
+ * Deletes all nodes from the collection that belong to the given document.
38
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
39
+ * @param deleteOptions Additional delete options.
40
+ */
36
41
  delete(refDocId: string, deleteOptions?: Omit<DeleteReq, "ids">): Promise<void>;
37
42
  toMilvusFilter(filters?: MetadataFilters): string | undefined;
38
43
  query(query: VectorStoreQuery, _options?: object): Promise<VectorStoreQueryResult>;
39
44
  persist(): Promise<void>;
45
+ exists(refDocId: string): Promise<boolean>;
40
46
  }
41
47
 
42
48
  export { MilvusVectorStore };
@@ -33,10 +33,16 @@ declare class MilvusVectorStore extends BaseVectorStore {
33
33
  private createCollection;
34
34
  private ensureCollection;
35
35
  add(nodes: BaseNode<Metadata>[]): Promise<string[]>;
36
+ /**
37
+ * Deletes all nodes from the collection that belong to the given document.
38
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
39
+ * @param deleteOptions Additional delete options.
40
+ */
36
41
  delete(refDocId: string, deleteOptions?: Omit<DeleteReq, "ids">): Promise<void>;
37
42
  toMilvusFilter(filters?: MetadataFilters): string | undefined;
38
43
  query(query: VectorStoreQuery, _options?: object): Promise<VectorStoreQueryResult>;
39
44
  persist(): Promise<void>;
45
+ exists(refDocId: string): Promise<boolean>;
40
46
  }
41
47
 
42
48
  export { MilvusVectorStore };
@@ -135,12 +135,14 @@ class MilvusVectorStore extends BaseVectorStore {
135
135
  }
136
136
  return result.IDs.str_id.data.map((s)=>String(s));
137
137
  }
138
- async delete(refDocId, deleteOptions) {
138
+ /**
139
+ * Deletes all nodes from the collection that belong to the given document.
140
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
141
+ * @param deleteOptions Additional delete options.
142
+ */ async delete(refDocId, deleteOptions) {
139
143
  await this.ensureCollection();
140
144
  await this.milvusClient.delete({
141
- ids: [
142
- refDocId
143
- ],
145
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
144
146
  collection_name: this.collectionName,
145
147
  ...deleteOptions
146
148
  });
@@ -177,6 +179,18 @@ class MilvusVectorStore extends BaseVectorStore {
177
179
  async persist() {
178
180
  // no need to do anything
179
181
  }
182
+ async exists(refDocId) {
183
+ await this.ensureCollection();
184
+ const result = await this.milvusClient.query({
185
+ collection_name: this.collectionName,
186
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
187
+ output_fields: [
188
+ this.idKey
189
+ ],
190
+ limit: 1
191
+ });
192
+ return result.data.length > 0;
193
+ }
180
194
  }
181
195
 
182
196
  export { MilvusVectorStore };
package/dist/index.js CHANGED
@@ -135,12 +135,14 @@ class MilvusVectorStore extends BaseVectorStore {
135
135
  }
136
136
  return result.IDs.str_id.data.map((s)=>String(s));
137
137
  }
138
- async delete(refDocId, deleteOptions) {
138
+ /**
139
+ * Deletes all nodes from the collection that belong to the given document.
140
+ * @param refDocId Reference document ID - all nodes with this ref_doc_id will be deleted.
141
+ * @param deleteOptions Additional delete options.
142
+ */ async delete(refDocId, deleteOptions) {
139
143
  await this.ensureCollection();
140
144
  await this.milvusClient.delete({
141
- ids: [
142
- refDocId
143
- ],
145
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
144
146
  collection_name: this.collectionName,
145
147
  ...deleteOptions
146
148
  });
@@ -177,6 +179,18 @@ class MilvusVectorStore extends BaseVectorStore {
177
179
  async persist() {
178
180
  // no need to do anything
179
181
  }
182
+ async exists(refDocId) {
183
+ await this.ensureCollection();
184
+ const result = await this.milvusClient.query({
185
+ collection_name: this.collectionName,
186
+ filter: `${this.metadataKey}["ref_doc_id"] == "${refDocId}"`,
187
+ output_fields: [
188
+ this.idKey
189
+ ],
190
+ limit: 1
191
+ });
192
+ return result.data.length > 0;
193
+ }
180
194
  }
181
195
 
182
196
  export { MilvusVectorStore };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vectorstores/milvus",
3
3
  "description": "Milvus Storage for vectorstores",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -35,11 +35,11 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "vitest": "^2.1.5",
38
- "@vectorstores/core": "0.1.3",
38
+ "@vectorstores/core": "0.1.5",
39
39
  "@vectorstores/env": "0.1.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@vectorstores/core": "0.1.3",
42
+ "@vectorstores/core": "0.1.5",
43
43
  "@vectorstores/env": "0.1.0"
44
44
  },
45
45
  "dependencies": {