@mastra/elasticsearch 1.4.1-alpha.0 → 1.4.1
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/README.md +15 -77
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,11 +8,6 @@ ElasticSearch vector store implementation for Mastra, providing vector similarit
|
|
|
8
8
|
npm install @mastra/elasticsearch
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Prerequisites
|
|
12
|
-
|
|
13
|
-
- ElasticSearch 8.x+ instance
|
|
14
|
-
- Dense vector support enabled (included by default in ES 8.x)
|
|
15
|
-
|
|
16
11
|
## Usage
|
|
17
12
|
|
|
18
13
|
### Vector Store
|
|
@@ -23,27 +18,30 @@ import { ElasticSearchVector } from '@mastra/elasticsearch';
|
|
|
23
18
|
const vectorDB = new ElasticSearchVector({
|
|
24
19
|
url: 'http://localhost:9200',
|
|
25
20
|
id: 'my-vector-store',
|
|
26
|
-
auth: { apiKey: 'insert-api-key' }
|
|
21
|
+
auth: { apiKey: 'insert-api-key' },
|
|
27
22
|
});
|
|
28
23
|
|
|
29
24
|
// Create a new vector index
|
|
30
25
|
await vectorDB.createIndex({
|
|
31
26
|
indexName: 'my_vectors',
|
|
32
|
-
dimension:
|
|
27
|
+
dimension: 3,
|
|
33
28
|
metric: 'cosine', // or 'euclidean', 'dotproduct'
|
|
34
29
|
});
|
|
35
30
|
|
|
36
31
|
// Upsert vectors
|
|
37
32
|
const ids = await vectorDB.upsert({
|
|
38
33
|
indexName: 'my_vectors',
|
|
39
|
-
vectors: [
|
|
34
|
+
vectors: [
|
|
35
|
+
[0.1, 0.2, 0.3],
|
|
36
|
+
[0.3, 0.4, 0.5],
|
|
37
|
+
],
|
|
40
38
|
metadata: [{ text: 'doc1' }, { text: 'doc2' }],
|
|
41
39
|
});
|
|
42
40
|
|
|
43
41
|
// Query vectors
|
|
44
42
|
const results = await vectorDB.query({
|
|
45
43
|
indexName: 'my_vectors',
|
|
46
|
-
queryVector: [0.1, 0.2,
|
|
44
|
+
queryVector: [0.1, 0.2, 0.3],
|
|
47
45
|
topK: 10,
|
|
48
46
|
filter: { text: 'doc1' },
|
|
49
47
|
includeVector: false,
|
|
@@ -54,7 +52,7 @@ await vectorDB.updateVector({
|
|
|
54
52
|
indexName: 'my_vectors',
|
|
55
53
|
id: 'vector-id',
|
|
56
54
|
update: {
|
|
57
|
-
vector: [0.5, 0.6,
|
|
55
|
+
vector: [0.5, 0.6, 0.7],
|
|
58
56
|
metadata: { text: 'updated' },
|
|
59
57
|
},
|
|
60
58
|
});
|
|
@@ -72,75 +70,15 @@ await vectorDB.deleteVectors({
|
|
|
72
70
|
});
|
|
73
71
|
```
|
|
74
72
|
|
|
75
|
-
##
|
|
76
|
-
|
|
77
|
-
The ElasticSearchVector store accepts either connection parameters or a pre-configured client:
|
|
78
|
-
|
|
79
|
-
### Using connection parameters
|
|
80
|
-
|
|
81
|
-
- `id`: A unique identifier for the vector store instance (required)
|
|
82
|
-
- `url`: The ElasticSearch node URL (required)
|
|
83
|
-
- `auth`: The authentication mechanism (optional)
|
|
84
|
-
- HTTP basic: `{ auth: { username: 'insert-username', password: 'insert-password' } }`
|
|
85
|
-
- API key: `{ auth: { apiKey: 'insert-api-key' } }`
|
|
86
|
-
- Bearer token: `{ auth: { bearer: 'insert-token' } }`
|
|
87
|
-
|
|
88
|
-
### Using a pre-configured client
|
|
89
|
-
|
|
90
|
-
- `id`: A unique identifier for the vector store instance (required)
|
|
91
|
-
- `client`: An existing `@elastic/elasticsearch` `Client` instance (required)
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
import { Client } from '@elastic/elasticsearch';
|
|
95
|
-
import { ElasticSearchVector } from '@mastra/elasticsearch';
|
|
96
|
-
|
|
97
|
-
const client = new Client({ node: 'http://localhost:9200' });
|
|
98
|
-
const vectorDB = new ElasticSearchVector({ id: 'my-vector-store', client });
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Features
|
|
102
|
-
|
|
103
|
-
### Vector Store Features
|
|
104
|
-
|
|
105
|
-
- **Create Index**: Create vector indexes with specified dimensions and similarity metrics
|
|
106
|
-
- **Upsert**: Insert or update vectors with optional metadata
|
|
107
|
-
- **Query**: Search for similar vectors with optional filtering
|
|
108
|
-
- **Update**: Update vector embeddings and/or metadata by ID or filter
|
|
109
|
-
- **Delete**: Remove vectors by ID or filter
|
|
110
|
-
- **List Indexes**: List all vector indexes
|
|
111
|
-
- **Describe Index**: Get index statistics (dimension, count, metric)
|
|
112
|
-
|
|
113
|
-
### Supported Similarity Metrics
|
|
114
|
-
|
|
115
|
-
- `cosine`: Cosine similarity (default)
|
|
116
|
-
- `euclidean`: L2 (Euclidean) distance
|
|
117
|
-
- `dotproduct`: Dot product similarity
|
|
118
|
-
|
|
119
|
-
### Filter Operators
|
|
73
|
+
## Documentation
|
|
120
74
|
|
|
121
|
-
|
|
75
|
+
- [Elasticsearch integration guide](https://mastra.ai/integrations/databases/elasticsearch)
|
|
76
|
+
- [Elasticsearch vector reference](https://mastra.ai/reference/vectors/elasticsearch)
|
|
122
77
|
|
|
123
|
-
|
|
124
|
-
- **Array**: `$in`, `$nin`, `$all`
|
|
125
|
-
- **Logical**: `$and`, `$or`, `$not`, `$nor`
|
|
126
|
-
- **Element**: `$exists`
|
|
127
|
-
- **Regex**: `$regex`
|
|
78
|
+
## Changelog
|
|
128
79
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Running Tests
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
# Start ElasticSearch container
|
|
135
|
-
docker compose up -d
|
|
136
|
-
|
|
137
|
-
# Run tests
|
|
138
|
-
pnpm test
|
|
139
|
-
|
|
140
|
-
# Stop container
|
|
141
|
-
docker compose down -v
|
|
142
|
-
```
|
|
80
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/elasticsearch/CHANGELOG.md) for version history and release notes.
|
|
143
81
|
|
|
144
|
-
##
|
|
82
|
+
## Support
|
|
145
83
|
|
|
146
|
-
|
|
84
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-elasticsearch
|
|
|
3
3
|
description: Documentation for @mastra/elasticsearch. Use when working with @mastra/elasticsearch APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/elasticsearch"
|
|
6
|
-
version: "1.4.1
|
|
6
|
+
version: "1.4.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ let crypto$1 = require("crypto");
|
|
|
31
31
|
crypto$1 = __toESM(crypto$1, 1);
|
|
32
32
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
33
33
|
//#region package.json
|
|
34
|
-
var version = "1.4.1
|
|
34
|
+
var version = "1.4.1";
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/vector/filter.ts
|
|
37
37
|
/**
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { MessageList } from "@mastra/core/agent";
|
|
|
7
7
|
import crypto$1 from "crypto";
|
|
8
8
|
import { saveScorePayloadSchema } from "@mastra/core/evals";
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "1.4.1
|
|
10
|
+
var version = "1.4.1";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/vector/filter.ts
|
|
13
13
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/elasticsearch",
|
|
3
|
-
"version": "1.4.1
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "ElasticSearch vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"tsx": "^4.23.1",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vitest": "4.1.10",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@
|
|
35
|
-
"@internal/
|
|
36
|
-
"@
|
|
33
|
+
"@internal/types-builder": "0.0.105",
|
|
34
|
+
"@mastra/core": "1.64.0",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.126",
|
|
36
|
+
"@internal/lint": "0.0.130"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@mastra/core": ">=1.61.0-0 <2.0.0-0"
|