@mastra/opensearch 0.10.0 → 0.10.1-alpha.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 +5 -5
- package/CHANGELOG.md +10 -0
- package/dist/_tsup-dts-rollup.d.cts +6 -0
- package/dist/_tsup-dts-rollup.d.ts +6 -0
- package/package.json +3 -3
- package/src/vector/prompt.ts +82 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/opensearch@0.10.
|
|
2
|
+
> @mastra/opensearch@0.10.1-alpha.0 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 9209ms
|
|
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 10807ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
20
|
[32mCJS[39m [1mdist/index.cjs [22m[32m21.76 KB[39m
|
|
21
|
-
[32mCJS[39m ⚡️ Build success in
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 763ms
|
|
22
22
|
[32mESM[39m [1mdist/index.js [22m[32m21.72 KB[39m
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 1003ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/opensearch
|
|
2
2
|
|
|
3
|
+
## 0.10.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 915ca1a: Added disconnect function for couchbase and added docs
|
|
8
|
+
Added prompt for OpenSearchVector
|
|
9
|
+
- Updated dependencies [ee77e78]
|
|
10
|
+
- Updated dependencies [2901125]
|
|
11
|
+
- @mastra/core@0.10.2-alpha.1
|
|
12
|
+
|
|
3
13
|
## 0.10.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -12,6 +12,12 @@ import type { UpdateVectorParams } from '@mastra/core';
|
|
|
12
12
|
import type { UpsertVectorParams } from '@mastra/core';
|
|
13
13
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
|
|
17
|
+
* Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OPENSEARCH_PROMPT = "When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Do not explain how to construct the filter\u2014use the specified operators and fields to search the content and return relevant results.\nIf a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default for field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRegex Operator:\n- $regex: Match using a regular expression (ECMAScript syntax)\n Example: { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.\n\nRestrictions:\n- Nested fields are supported using dot notation (e.g., \"address.city\").\n- Multiple conditions on the same field are supported (e.g., { \"price\": { \"$gte\": 100, \"$lte\": 1000 } }).\n- Only logical operators ($and, $or, $not) can be used at the top level.\n- All other operators must be used within a field condition.\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators.\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Array operators work on array fields only.\n- Empty arrays in conditions are handled gracefully.\n- Regex queries are case-sensitive by default; use patterns accordingly.\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n ]\n}";
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Translator for OpenSearch filter queries.
|
|
17
23
|
* Maintains OpenSearch-compatible syntax while ensuring proper validation
|
|
@@ -12,6 +12,12 @@ import type { UpdateVectorParams } from '@mastra/core';
|
|
|
12
12
|
import type { UpsertVectorParams } from '@mastra/core';
|
|
13
13
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
|
|
17
|
+
* Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OPENSEARCH_PROMPT = "When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Do not explain how to construct the filter\u2014use the specified operators and fields to search the content and return relevant results.\nIf a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default for field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRegex Operator:\n- $regex: Match using a regular expression (ECMAScript syntax)\n Example: { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.\n\nRestrictions:\n- Nested fields are supported using dot notation (e.g., \"address.city\").\n- Multiple conditions on the same field are supported (e.g., { \"price\": { \"$gte\": 100, \"$lte\": 1000 } }).\n- Only logical operators ($and, $or, $not) can be used at the top level.\n- All other operators must be used within a field condition.\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators.\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Array operators work on array fields only.\n- Empty arrays in conditions are handled gracefully.\n- Regex queries are case-sensitive by default; use patterns accordingly.\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n ]\n}";
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Translator for OpenSearch filter queries.
|
|
17
23
|
* Maintains OpenSearch-compatible syntax while ensuring proper validation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/opensearch",
|
|
3
|
-
"version": "0.10.0",
|
|
3
|
+
"version": "0.10.1-alpha.0",
|
|
4
4
|
"description": "OpenSearch vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tsup": "^8.4.0",
|
|
29
29
|
"typescript": "^5.8.2",
|
|
30
30
|
"vitest": "^3.0.8",
|
|
31
|
-
"@internal/lint": "0.0.
|
|
32
|
-
"@mastra/core": "0.10.
|
|
31
|
+
"@internal/lint": "0.0.7",
|
|
32
|
+
"@mastra/core": "0.10.2-alpha.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@mastra/core": "^0.10.0"
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
|
|
3
|
+
* Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
|
|
4
|
+
*/
|
|
5
|
+
export const OPENSEARCH_PROMPT = `When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
6
|
+
Important: Do not explain how to construct the filter—use the specified operators and fields to search the content and return relevant results.
|
|
7
|
+
If a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.
|
|
8
|
+
|
|
9
|
+
Basic Comparison Operators:
|
|
10
|
+
- $eq: Exact match (default for field: value)
|
|
11
|
+
Example: { "category": "electronics" }
|
|
12
|
+
- $ne: Not equal
|
|
13
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
14
|
+
- $gt: Greater than
|
|
15
|
+
Example: { "price": { "$gt": 100 } }
|
|
16
|
+
- $gte: Greater than or equal
|
|
17
|
+
Example: { "price": { "$gte": 100 } }
|
|
18
|
+
- $lt: Less than
|
|
19
|
+
Example: { "price": { "$lt": 100 } }
|
|
20
|
+
- $lte: Less than or equal
|
|
21
|
+
Example: { "price": { "$lte": 100 } }
|
|
22
|
+
|
|
23
|
+
Array Operators:
|
|
24
|
+
- $in: Match any value in array
|
|
25
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
26
|
+
- $nin: Does not match any value in array
|
|
27
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
28
|
+
- $all: Match all values in array
|
|
29
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
30
|
+
|
|
31
|
+
Logical Operators:
|
|
32
|
+
- $and: Logical AND (implicit when using multiple conditions)
|
|
33
|
+
Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
34
|
+
- $or: Logical OR
|
|
35
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
36
|
+
- $not: Logical NOT
|
|
37
|
+
Example: { "$not": { "category": "electronics" } }
|
|
38
|
+
|
|
39
|
+
Element Operators:
|
|
40
|
+
- $exists: Check if field exists
|
|
41
|
+
Example: { "rating": { "$exists": true } }
|
|
42
|
+
|
|
43
|
+
Regex Operator:
|
|
44
|
+
- $regex: Match using a regular expression (ECMAScript syntax)
|
|
45
|
+
Example: { "name": { "$regex": "^Sam.*son$" } }
|
|
46
|
+
Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.
|
|
47
|
+
|
|
48
|
+
Restrictions:
|
|
49
|
+
- Nested fields are supported using dot notation (e.g., "address.city").
|
|
50
|
+
- Multiple conditions on the same field are supported (e.g., { "price": { "$gte": 100, "$lte": 1000 } }).
|
|
51
|
+
- Only logical operators ($and, $or, $not) can be used at the top level.
|
|
52
|
+
- All other operators must be used within a field condition.
|
|
53
|
+
Valid: { "field": { "$gt": 100 } }
|
|
54
|
+
Valid: { "$and": [...] }
|
|
55
|
+
Invalid: { "$gt": 100 }
|
|
56
|
+
- Logical operators must contain field conditions, not direct operators.
|
|
57
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
58
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
59
|
+
- $not operator:
|
|
60
|
+
- Must be an object
|
|
61
|
+
- Cannot be empty
|
|
62
|
+
- Can be used at field level or top level
|
|
63
|
+
- Valid: { "$not": { "field": "value" } }
|
|
64
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
65
|
+
- Array operators work on array fields only.
|
|
66
|
+
- Empty arrays in conditions are handled gracefully.
|
|
67
|
+
- Regex queries are case-sensitive by default; use patterns accordingly.
|
|
68
|
+
|
|
69
|
+
Example Complex Query:
|
|
70
|
+
{
|
|
71
|
+
"$and": [
|
|
72
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
73
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
74
|
+
{ "tags": { "$all": ["premium"] } },
|
|
75
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
76
|
+
{ "$or": [
|
|
77
|
+
{ "stock": { "$gt": 0 } },
|
|
78
|
+
{ "preorder": true }
|
|
79
|
+
]},
|
|
80
|
+
{ "name": { "$regex": "^Sam.*son$" } }
|
|
81
|
+
]
|
|
82
|
+
}`;
|