@mastra/opensearch 0.0.0-cloud-transporter-20250513033346 → 0.1.0
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 +23 -0
- package/CHANGELOG.md +0 -47
- package/dist/_tsup-dts-rollup.d.cts +11 -37
- package/dist/_tsup-dts-rollup.d.ts +11 -37
- package/dist/index.cjs +11 -48
- package/dist/index.js +11 -48
- package/package.json +3 -3
- package/src/vector/index.test.ts +5 -5
- package/src/vector/index.ts +11 -54
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
> @mastra/opensearch@0.1.0-alpha.0 build /home/runner/work/mastra/mastra/stores/opensearch
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.4.0
|
|
8
|
+
[34mTSC[39m Build start
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 11259ms
|
|
10
|
+
[34mDTS[39m Build start
|
|
11
|
+
[34mCLI[39m Target: es2022
|
|
12
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 10586ms
|
|
17
|
+
[34mCLI[39m Cleaning output folder
|
|
18
|
+
[34mESM[39m Build start
|
|
19
|
+
[34mCJS[39m Build start
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m21.32 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 986ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m21.37 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 985ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
1
|
# @mastra/opensearch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-cloud-transporter-20250513033346
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
8
|
-
- Updated dependencies [396be50]
|
|
9
|
-
- Updated dependencies [ab80e7e]
|
|
10
|
-
- Updated dependencies [c3bd795]
|
|
11
|
-
- Updated dependencies [da082f8]
|
|
12
|
-
- Updated dependencies [a5810ce]
|
|
13
|
-
- Updated dependencies [3171b5b]
|
|
14
|
-
- Updated dependencies [973e5ac]
|
|
15
|
-
- Updated dependencies [daf942f]
|
|
16
|
-
- Updated dependencies [0b8b868]
|
|
17
|
-
- Updated dependencies [9e1eff5]
|
|
18
|
-
- Updated dependencies [6fa1ad1]
|
|
19
|
-
- Updated dependencies [c28d7a0]
|
|
20
|
-
- Updated dependencies [edf1e88]
|
|
21
|
-
- @mastra/core@0.0.0-cloud-transporter-20250513033346
|
|
22
|
-
|
|
23
|
-
## 0.1.1-alpha.2
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- Updated dependencies [3171b5b]
|
|
28
|
-
- Updated dependencies [973e5ac]
|
|
29
|
-
- Updated dependencies [9e1eff5]
|
|
30
|
-
- @mastra/core@0.9.4-alpha.2
|
|
31
|
-
|
|
32
|
-
## 0.1.1-alpha.1
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
- Updated dependencies [ab80e7e]
|
|
37
|
-
- Updated dependencies [6fa1ad1]
|
|
38
|
-
- Updated dependencies [c28d7a0]
|
|
39
|
-
- Updated dependencies [edf1e88]
|
|
40
|
-
- @mastra/core@0.9.4-alpha.1
|
|
41
|
-
|
|
42
|
-
## 0.1.1-alpha.0
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- Updated dependencies [daf942f]
|
|
47
|
-
- Updated dependencies [0b8b868]
|
|
48
|
-
- @mastra/core@0.9.4-alpha.0
|
|
49
|
-
|
|
50
3
|
## 0.1.0
|
|
51
4
|
|
|
52
5
|
### Patch Changes
|
|
@@ -111,53 +111,27 @@ declare class OpenSearchVector extends MastraVector {
|
|
|
111
111
|
*/
|
|
112
112
|
private transformFilter;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Updates a specific document in the index by ID.
|
|
115
115
|
*
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param update -
|
|
120
|
-
* @param update.
|
|
121
|
-
* @
|
|
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.
|
|
116
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
117
|
+
* @param {string} id - The ID of the document to update.
|
|
118
|
+
* @param {Object} update - The update to apply to the document.
|
|
119
|
+
* @param {number[]} [update.vector] - Optional new vector to update.
|
|
120
|
+
* @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
|
|
121
|
+
* @returns {Promise<void>} A promise that resolves when the document is updated.
|
|
124
122
|
*/
|
|
125
123
|
updateIndexById(indexName: string, id: string, update: {
|
|
126
124
|
vector?: number[];
|
|
127
125
|
metadata?: Record<string, any>;
|
|
128
126
|
}): Promise<void>;
|
|
129
127
|
/**
|
|
130
|
-
*
|
|
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.
|
|
128
|
+
* Deletes a specific document from the index by ID.
|
|
145
129
|
*
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
* @
|
|
149
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
150
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
130
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
131
|
+
* @param {string} id - The ID of the document to delete.
|
|
132
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
151
133
|
*/
|
|
152
134
|
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>;
|
|
161
135
|
}
|
|
162
136
|
export { OpenSearchVector }
|
|
163
137
|
export { OpenSearchVector as OpenSearchVector_alias_1 }
|
|
@@ -111,53 +111,27 @@ declare class OpenSearchVector extends MastraVector {
|
|
|
111
111
|
*/
|
|
112
112
|
private transformFilter;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Updates a specific document in the index by ID.
|
|
115
115
|
*
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param update -
|
|
120
|
-
* @param update.
|
|
121
|
-
* @
|
|
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.
|
|
116
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
117
|
+
* @param {string} id - The ID of the document to update.
|
|
118
|
+
* @param {Object} update - The update to apply to the document.
|
|
119
|
+
* @param {number[]} [update.vector] - Optional new vector to update.
|
|
120
|
+
* @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
|
|
121
|
+
* @returns {Promise<void>} A promise that resolves when the document is updated.
|
|
124
122
|
*/
|
|
125
123
|
updateIndexById(indexName: string, id: string, update: {
|
|
126
124
|
vector?: number[];
|
|
127
125
|
metadata?: Record<string, any>;
|
|
128
126
|
}): Promise<void>;
|
|
129
127
|
/**
|
|
130
|
-
*
|
|
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.
|
|
128
|
+
* Deletes a specific document from the index by ID.
|
|
145
129
|
*
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
* @
|
|
149
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
150
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
130
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
131
|
+
* @param {string} id - The ID of the document to delete.
|
|
132
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
151
133
|
*/
|
|
152
134
|
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>;
|
|
161
135
|
}
|
|
162
136
|
export { OpenSearchVector }
|
|
163
137
|
export { OpenSearchVector as OpenSearchVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -558,36 +558,16 @@ var OpenSearchVector = class extends vector.MastraVector {
|
|
|
558
558
|
return translator.translate(filter);
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
561
|
-
*
|
|
561
|
+
* Updates a specific document in the index by ID.
|
|
562
562
|
*
|
|
563
|
-
*
|
|
564
|
-
* @param
|
|
565
|
-
* @param
|
|
566
|
-
* @param update -
|
|
567
|
-
* @param update.
|
|
568
|
-
* @
|
|
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.
|
|
563
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
564
|
+
* @param {string} id - The ID of the document to update.
|
|
565
|
+
* @param {Object} update - The update to apply to the document.
|
|
566
|
+
* @param {number[]} [update.vector] - Optional new vector to update.
|
|
567
|
+
* @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
|
|
568
|
+
* @returns {Promise<void>} A promise that resolves when the document is updated.
|
|
571
569
|
*/
|
|
572
570
|
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) {
|
|
591
571
|
if (!update.vector && !update.metadata) {
|
|
592
572
|
throw new Error("No updates provided");
|
|
593
573
|
}
|
|
@@ -629,30 +609,13 @@ var OpenSearchVector = class extends vector.MastraVector {
|
|
|
629
609
|
}
|
|
630
610
|
}
|
|
631
611
|
/**
|
|
632
|
-
*
|
|
612
|
+
* Deletes a specific document from the index by ID.
|
|
633
613
|
*
|
|
634
|
-
*
|
|
635
|
-
* @param
|
|
636
|
-
* @
|
|
637
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
638
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
614
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
615
|
+
* @param {string} id - The ID of the document to delete.
|
|
616
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
639
617
|
*/
|
|
640
618
|
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) {
|
|
656
619
|
try {
|
|
657
620
|
await this.client.delete({
|
|
658
621
|
index: indexName,
|
package/dist/index.js
CHANGED
|
@@ -556,36 +556,16 @@ var OpenSearchVector = class extends MastraVector {
|
|
|
556
556
|
return translator.translate(filter);
|
|
557
557
|
}
|
|
558
558
|
/**
|
|
559
|
-
*
|
|
559
|
+
* Updates a specific document in the index by ID.
|
|
560
560
|
*
|
|
561
|
-
*
|
|
562
|
-
* @param
|
|
563
|
-
* @param
|
|
564
|
-
* @param update -
|
|
565
|
-
* @param update.
|
|
566
|
-
* @
|
|
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.
|
|
561
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
562
|
+
* @param {string} id - The ID of the document to update.
|
|
563
|
+
* @param {Object} update - The update to apply to the document.
|
|
564
|
+
* @param {number[]} [update.vector] - Optional new vector to update.
|
|
565
|
+
* @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
|
|
566
|
+
* @returns {Promise<void>} A promise that resolves when the document is updated.
|
|
569
567
|
*/
|
|
570
568
|
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) {
|
|
589
569
|
if (!update.vector && !update.metadata) {
|
|
590
570
|
throw new Error("No updates provided");
|
|
591
571
|
}
|
|
@@ -627,30 +607,13 @@ var OpenSearchVector = class extends MastraVector {
|
|
|
627
607
|
}
|
|
628
608
|
}
|
|
629
609
|
/**
|
|
630
|
-
*
|
|
610
|
+
* Deletes a specific document from the index by ID.
|
|
631
611
|
*
|
|
632
|
-
*
|
|
633
|
-
* @param
|
|
634
|
-
* @
|
|
635
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
636
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
612
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
613
|
+
* @param {string} id - The ID of the document to delete.
|
|
614
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
637
615
|
*/
|
|
638
616
|
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) {
|
|
654
617
|
try {
|
|
655
618
|
await this.client.delete({
|
|
656
619
|
index: indexName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/opensearch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
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.
|
|
23
|
+
"@mastra/core": "^0.9.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"tsup": "^8.4.0",
|
|
30
30
|
"typescript": "^5.8.2",
|
|
31
31
|
"vitest": "^3.0.8",
|
|
32
|
-
"@internal/lint": "0.0.
|
|
32
|
+
"@internal/lint": "0.0.4"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
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.updateIndexById(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.updateIndexById(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.updateIndexById(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.updateIndexById(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.deleteIndexById(testIndexName, idToBeDeleted);
|
|
598
598
|
|
|
599
599
|
const results: QueryResult[] = await vectorDB.query({
|
|
600
600
|
indexName: testIndexName,
|
package/src/vector/index.ts
CHANGED
|
@@ -244,41 +244,16 @@ export class OpenSearchVector extends MastraVector {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
247
|
+
* Updates a specific document in the index by ID.
|
|
248
248
|
*
|
|
249
|
-
*
|
|
250
|
-
* @param
|
|
251
|
-
* @param
|
|
252
|
-
* @param update -
|
|
253
|
-
* @param update.
|
|
254
|
-
* @
|
|
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.
|
|
249
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
250
|
+
* @param {string} id - The ID of the document to update.
|
|
251
|
+
* @param {Object} update - The update to apply to the document.
|
|
252
|
+
* @param {number[]} [update.vector] - Optional new vector to update.
|
|
253
|
+
* @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
|
|
254
|
+
* @returns {Promise<void>} A promise that resolves when the document is updated.
|
|
257
255
|
*/
|
|
258
256
|
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(
|
|
282
257
|
indexName: string,
|
|
283
258
|
id: string,
|
|
284
259
|
update: {
|
|
@@ -344,31 +319,13 @@ export class OpenSearchVector extends MastraVector {
|
|
|
344
319
|
}
|
|
345
320
|
|
|
346
321
|
/**
|
|
347
|
-
*
|
|
322
|
+
* Deletes a specific document from the index by ID.
|
|
348
323
|
*
|
|
349
|
-
*
|
|
350
|
-
* @param
|
|
351
|
-
* @
|
|
352
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
353
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
324
|
+
* @param {string} indexName - The name of the index containing the document.
|
|
325
|
+
* @param {string} id - The ID of the document to delete.
|
|
326
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
354
327
|
*/
|
|
355
328
|
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> {
|
|
372
329
|
try {
|
|
373
330
|
await this.client.delete({
|
|
374
331
|
index: indexName,
|