@mastra/opensearch 0.1.1-alpha.2 → 0.1.1-alpha.4
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +18 -0
- package/dist/_tsup-dts-rollup.d.cts +37 -11
- package/dist/_tsup-dts-rollup.d.ts +37 -11
- package/dist/index.cjs +48 -11
- package/dist/index.js +48 -11
- package/package.json +2 -2
- package/src/vector/index.test.ts +5 -5
- package/src/vector/index.ts +54 -11
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/opensearch@0.1.1-alpha.
|
|
2
|
+
> @mastra/opensearch@0.1.1-alpha.4 build /home/runner/work/mastra/mastra/stores/opensearch
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 9556ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 10879ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m23.06 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1008ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m23.10 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1007ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/opensearch
|
|
2
2
|
|
|
3
|
+
## 0.1.1-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [3e9c131]
|
|
8
|
+
- @mastra/core@0.9.4-alpha.4
|
|
9
|
+
|
|
10
|
+
## 0.1.1-alpha.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
15
|
+
- Updated dependencies [396be50]
|
|
16
|
+
- Updated dependencies [c3bd795]
|
|
17
|
+
- Updated dependencies [da082f8]
|
|
18
|
+
- Updated dependencies [a5810ce]
|
|
19
|
+
- @mastra/core@0.9.4-alpha.3
|
|
20
|
+
|
|
3
21
|
## 0.1.1-alpha.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -111,27 +111,53 @@ declare class OpenSearchVector extends MastraVector {
|
|
|
111
111
|
*/
|
|
112
112
|
private transformFilter;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
115
115
|
*
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @
|
|
116
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
117
|
+
* @param indexName - The name of the index containing the vector.
|
|
118
|
+
* @param id - The ID of the vector to update.
|
|
119
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
120
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
121
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
122
|
+
* @returns A promise that resolves when the update is complete.
|
|
123
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
122
124
|
*/
|
|
123
125
|
updateIndexById(indexName: string, id: string, update: {
|
|
124
126
|
vector?: number[];
|
|
125
127
|
metadata?: Record<string, any>;
|
|
126
128
|
}): Promise<void>;
|
|
127
129
|
/**
|
|
128
|
-
*
|
|
130
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
131
|
+
* @param indexName - The name of the index containing the vector.
|
|
132
|
+
* @param id - The ID of the vector to update.
|
|
133
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
134
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
135
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
136
|
+
* @returns A promise that resolves when the update is complete.
|
|
137
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
138
|
+
*/
|
|
139
|
+
updateVector(indexName: string, id: string, update: {
|
|
140
|
+
vector?: number[];
|
|
141
|
+
metadata?: Record<string, any>;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
129
145
|
*
|
|
130
|
-
*
|
|
131
|
-
* @param
|
|
132
|
-
* @
|
|
146
|
+
* Deletes a vector by its ID.
|
|
147
|
+
* @param indexName - The name of the index containing the vector.
|
|
148
|
+
* @param id - The ID of the vector to delete.
|
|
149
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
150
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
133
151
|
*/
|
|
134
152
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Deletes a vector by its ID.
|
|
155
|
+
* @param indexName - The name of the index containing the vector.
|
|
156
|
+
* @param id - The ID of the vector to delete.
|
|
157
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
158
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
159
|
+
*/
|
|
160
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
135
161
|
}
|
|
136
162
|
export { OpenSearchVector }
|
|
137
163
|
export { OpenSearchVector as OpenSearchVector_alias_1 }
|
|
@@ -111,27 +111,53 @@ declare class OpenSearchVector extends MastraVector {
|
|
|
111
111
|
*/
|
|
112
112
|
private transformFilter;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
115
115
|
*
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @
|
|
116
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
117
|
+
* @param indexName - The name of the index containing the vector.
|
|
118
|
+
* @param id - The ID of the vector to update.
|
|
119
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
120
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
121
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
122
|
+
* @returns A promise that resolves when the update is complete.
|
|
123
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
122
124
|
*/
|
|
123
125
|
updateIndexById(indexName: string, id: string, update: {
|
|
124
126
|
vector?: number[];
|
|
125
127
|
metadata?: Record<string, any>;
|
|
126
128
|
}): Promise<void>;
|
|
127
129
|
/**
|
|
128
|
-
*
|
|
130
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
131
|
+
* @param indexName - The name of the index containing the vector.
|
|
132
|
+
* @param id - The ID of the vector to update.
|
|
133
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
134
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
135
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
136
|
+
* @returns A promise that resolves when the update is complete.
|
|
137
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
138
|
+
*/
|
|
139
|
+
updateVector(indexName: string, id: string, update: {
|
|
140
|
+
vector?: number[];
|
|
141
|
+
metadata?: Record<string, any>;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
129
145
|
*
|
|
130
|
-
*
|
|
131
|
-
* @param
|
|
132
|
-
* @
|
|
146
|
+
* Deletes a vector by its ID.
|
|
147
|
+
* @param indexName - The name of the index containing the vector.
|
|
148
|
+
* @param id - The ID of the vector to delete.
|
|
149
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
150
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
133
151
|
*/
|
|
134
152
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Deletes a vector by its ID.
|
|
155
|
+
* @param indexName - The name of the index containing the vector.
|
|
156
|
+
* @param id - The ID of the vector to delete.
|
|
157
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
158
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
159
|
+
*/
|
|
160
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
135
161
|
}
|
|
136
162
|
export { OpenSearchVector }
|
|
137
163
|
export { OpenSearchVector as OpenSearchVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -558,16 +558,36 @@ var OpenSearchVector = class extends vector.MastraVector {
|
|
|
558
558
|
return translator.translate(filter);
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
561
|
-
*
|
|
561
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
562
562
|
*
|
|
563
|
-
*
|
|
564
|
-
* @param
|
|
565
|
-
* @param
|
|
566
|
-
* @param
|
|
567
|
-
* @param
|
|
568
|
-
* @
|
|
563
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
564
|
+
* @param indexName - The name of the index containing the vector.
|
|
565
|
+
* @param id - The ID of the vector to update.
|
|
566
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
567
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
568
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
569
|
+
* @returns A promise that resolves when the update is complete.
|
|
570
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
569
571
|
*/
|
|
570
572
|
async updateIndexById(indexName, id, update) {
|
|
573
|
+
this.logger.warn(
|
|
574
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
575
|
+
Please use updateVector() instead.
|
|
576
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
577
|
+
);
|
|
578
|
+
await this.updateVector(indexName, id, update);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
582
|
+
* @param indexName - The name of the index containing the vector.
|
|
583
|
+
* @param id - The ID of the vector to update.
|
|
584
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
585
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
586
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
587
|
+
* @returns A promise that resolves when the update is complete.
|
|
588
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
589
|
+
*/
|
|
590
|
+
async updateVector(indexName, id, update) {
|
|
571
591
|
if (!update.vector && !update.metadata) {
|
|
572
592
|
throw new Error("No updates provided");
|
|
573
593
|
}
|
|
@@ -609,13 +629,30 @@ var OpenSearchVector = class extends vector.MastraVector {
|
|
|
609
629
|
}
|
|
610
630
|
}
|
|
611
631
|
/**
|
|
612
|
-
*
|
|
632
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
613
633
|
*
|
|
614
|
-
*
|
|
615
|
-
* @param
|
|
616
|
-
* @
|
|
634
|
+
* Deletes a vector by its ID.
|
|
635
|
+
* @param indexName - The name of the index containing the vector.
|
|
636
|
+
* @param id - The ID of the vector to delete.
|
|
637
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
638
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
617
639
|
*/
|
|
618
640
|
async deleteIndexById(indexName, id) {
|
|
641
|
+
this.logger.warn(
|
|
642
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
643
|
+
Please use deleteVector() instead.
|
|
644
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
645
|
+
);
|
|
646
|
+
await this.deleteVector(indexName, id);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Deletes a vector by its ID.
|
|
650
|
+
* @param indexName - The name of the index containing the vector.
|
|
651
|
+
* @param id - The ID of the vector to delete.
|
|
652
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
653
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
654
|
+
*/
|
|
655
|
+
async deleteVector(indexName, id) {
|
|
619
656
|
try {
|
|
620
657
|
await this.client.delete({
|
|
621
658
|
index: indexName,
|
package/dist/index.js
CHANGED
|
@@ -556,16 +556,36 @@ var OpenSearchVector = class extends MastraVector {
|
|
|
556
556
|
return translator.translate(filter);
|
|
557
557
|
}
|
|
558
558
|
/**
|
|
559
|
-
*
|
|
559
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
560
560
|
*
|
|
561
|
-
*
|
|
562
|
-
* @param
|
|
563
|
-
* @param
|
|
564
|
-
* @param
|
|
565
|
-
* @param
|
|
566
|
-
* @
|
|
561
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
562
|
+
* @param indexName - The name of the index containing the vector.
|
|
563
|
+
* @param id - The ID of the vector to update.
|
|
564
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
565
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
566
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
567
|
+
* @returns A promise that resolves when the update is complete.
|
|
568
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
567
569
|
*/
|
|
568
570
|
async updateIndexById(indexName, id, update) {
|
|
571
|
+
this.logger.warn(
|
|
572
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
573
|
+
Please use updateVector() instead.
|
|
574
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
575
|
+
);
|
|
576
|
+
await this.updateVector(indexName, id, update);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
580
|
+
* @param indexName - The name of the index containing the vector.
|
|
581
|
+
* @param id - The ID of the vector to update.
|
|
582
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
583
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
584
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
585
|
+
* @returns A promise that resolves when the update is complete.
|
|
586
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
587
|
+
*/
|
|
588
|
+
async updateVector(indexName, id, update) {
|
|
569
589
|
if (!update.vector && !update.metadata) {
|
|
570
590
|
throw new Error("No updates provided");
|
|
571
591
|
}
|
|
@@ -607,13 +627,30 @@ var OpenSearchVector = class extends MastraVector {
|
|
|
607
627
|
}
|
|
608
628
|
}
|
|
609
629
|
/**
|
|
610
|
-
*
|
|
630
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
611
631
|
*
|
|
612
|
-
*
|
|
613
|
-
* @param
|
|
614
|
-
* @
|
|
632
|
+
* Deletes a vector by its ID.
|
|
633
|
+
* @param indexName - The name of the index containing the vector.
|
|
634
|
+
* @param id - The ID of the vector to delete.
|
|
635
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
636
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
615
637
|
*/
|
|
616
638
|
async deleteIndexById(indexName, id) {
|
|
639
|
+
this.logger.warn(
|
|
640
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
641
|
+
Please use deleteVector() instead.
|
|
642
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
643
|
+
);
|
|
644
|
+
await this.deleteVector(indexName, id);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Deletes a vector by its ID.
|
|
648
|
+
* @param indexName - The name of the index containing the vector.
|
|
649
|
+
* @param id - The ID of the vector to delete.
|
|
650
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
651
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
652
|
+
*/
|
|
653
|
+
async deleteVector(indexName, id) {
|
|
617
654
|
try {
|
|
618
655
|
await this.client.delete({
|
|
619
656
|
index: indexName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/opensearch",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.4",
|
|
4
4
|
"description": "OpenSearch vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@opensearch-project/opensearch": "^3.4.0",
|
|
23
|
-
"@mastra/core": "^0.9.4-alpha.
|
|
23
|
+
"@mastra/core": "^0.9.4-alpha.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.1",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -503,7 +503,7 @@ describe('OpenSearchVector', () => {
|
|
|
503
503
|
metadata: newMetaData,
|
|
504
504
|
};
|
|
505
505
|
|
|
506
|
-
await vectorDB.
|
|
506
|
+
await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
|
|
507
507
|
|
|
508
508
|
const results: QueryResult[] = await vectorDB.query({
|
|
509
509
|
indexName: testIndexName,
|
|
@@ -530,7 +530,7 @@ describe('OpenSearchVector', () => {
|
|
|
530
530
|
metadata: newMetaData,
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
-
await vectorDB.
|
|
533
|
+
await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
|
|
534
534
|
|
|
535
535
|
const results: QueryResult[] = await vectorDB.query({
|
|
536
536
|
indexName: testIndexName,
|
|
@@ -555,7 +555,7 @@ describe('OpenSearchVector', () => {
|
|
|
555
555
|
vector: newVector,
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
-
await vectorDB.
|
|
558
|
+
await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
|
|
559
559
|
|
|
560
560
|
const results: QueryResult[] = await vectorDB.query({
|
|
561
561
|
indexName: testIndexName,
|
|
@@ -569,7 +569,7 @@ describe('OpenSearchVector', () => {
|
|
|
569
569
|
});
|
|
570
570
|
|
|
571
571
|
it('should throw exception when no updates are given', async () => {
|
|
572
|
-
await expect(vectorDB.
|
|
572
|
+
await expect(vectorDB.updateVector(testIndexName, 'id', {})).rejects.toThrow('No updates provided');
|
|
573
573
|
});
|
|
574
574
|
});
|
|
575
575
|
|
|
@@ -594,7 +594,7 @@ describe('OpenSearchVector', () => {
|
|
|
594
594
|
expect(ids).toHaveLength(3);
|
|
595
595
|
const idToBeDeleted = ids[0];
|
|
596
596
|
|
|
597
|
-
await vectorDB.
|
|
597
|
+
await vectorDB.deleteVector(testIndexName, idToBeDeleted);
|
|
598
598
|
|
|
599
599
|
const results: QueryResult[] = await vectorDB.query({
|
|
600
600
|
indexName: testIndexName,
|
package/src/vector/index.ts
CHANGED
|
@@ -244,16 +244,41 @@ export class OpenSearchVector extends MastraVector {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
247
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
248
248
|
*
|
|
249
|
-
*
|
|
250
|
-
* @param
|
|
251
|
-
* @param
|
|
252
|
-
* @param
|
|
253
|
-
* @param
|
|
254
|
-
* @
|
|
249
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
250
|
+
* @param indexName - The name of the index containing the vector.
|
|
251
|
+
* @param id - The ID of the vector to update.
|
|
252
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
253
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
254
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
255
|
+
* @returns A promise that resolves when the update is complete.
|
|
256
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
255
257
|
*/
|
|
256
258
|
async updateIndexById(
|
|
259
|
+
indexName: string,
|
|
260
|
+
id: string,
|
|
261
|
+
update: { vector?: number[]; metadata?: Record<string, any> },
|
|
262
|
+
): Promise<void> {
|
|
263
|
+
this.logger.warn(
|
|
264
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
265
|
+
Please use updateVector() instead.
|
|
266
|
+
updateIndexById() will be removed on May 20th, 2025.`,
|
|
267
|
+
);
|
|
268
|
+
await this.updateVector(indexName, id, update);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
273
|
+
* @param indexName - The name of the index containing the vector.
|
|
274
|
+
* @param id - The ID of the vector to update.
|
|
275
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
276
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
277
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
278
|
+
* @returns A promise that resolves when the update is complete.
|
|
279
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
280
|
+
*/
|
|
281
|
+
async updateVector(
|
|
257
282
|
indexName: string,
|
|
258
283
|
id: string,
|
|
259
284
|
update: {
|
|
@@ -319,13 +344,31 @@ export class OpenSearchVector extends MastraVector {
|
|
|
319
344
|
}
|
|
320
345
|
|
|
321
346
|
/**
|
|
322
|
-
*
|
|
347
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
323
348
|
*
|
|
324
|
-
*
|
|
325
|
-
* @param
|
|
326
|
-
* @
|
|
349
|
+
* Deletes a vector by its ID.
|
|
350
|
+
* @param indexName - The name of the index containing the vector.
|
|
351
|
+
* @param id - The ID of the vector to delete.
|
|
352
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
353
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
327
354
|
*/
|
|
328
355
|
async deleteIndexById(indexName: string, id: string): Promise<void> {
|
|
356
|
+
this.logger.warn(
|
|
357
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
358
|
+
Please use deleteVector() instead.
|
|
359
|
+
deleteIndexById() will be removed on May 20th, 2025.`,
|
|
360
|
+
);
|
|
361
|
+
await this.deleteVector(indexName, id);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Deletes a vector by its ID.
|
|
366
|
+
* @param indexName - The name of the index containing the vector.
|
|
367
|
+
* @param id - The ID of the vector to delete.
|
|
368
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
369
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
370
|
+
*/
|
|
371
|
+
async deleteVector(indexName: string, id: string): Promise<void> {
|
|
329
372
|
try {
|
|
330
373
|
await this.client.delete({
|
|
331
374
|
index: indexName,
|