@mastra/elasticsearch 1.3.0 → 1.3.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/dist/index.d.cts CHANGED
@@ -1,140 +1,142 @@
1
- import { Client } from '@elastic/elasticsearch';
2
- import { MastraVector, CreateIndexParams, DescribeIndexParams, IndexStats, DeleteIndexParams, UpsertVectorParams, QueryVectorParams, QueryResult, UpdateVectorParams, DeleteVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
3
- import { VectorFilter, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
4
-
1
+ import { Client } from "@elastic/elasticsearch";
2
+ import { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DeleteVectorsParams, DescribeIndexParams, IndexStats, MastraVector, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams } from "@mastra/core/vector";
3
+ import { BlacklistedRootOperators, LogicalOperatorValueMap, OperatorValueMap, VectorFilter } from "@mastra/core/vector/filter";
4
+ //#region src/vector/filter.d.ts
5
5
  type ElasticSearchOperatorValueMap = Omit<OperatorValueMap, '$options' | '$nor' | '$elemMatch'>;
6
6
  type ElasticSearchLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;
7
7
  type ElasticSearchBlacklisted = BlacklistedRootOperators | '$nor';
8
8
  type ElasticSearchVectorFilter = VectorFilter<keyof ElasticSearchOperatorValueMap, ElasticSearchOperatorValueMap, ElasticSearchLogicalOperatorValueMap, ElasticSearchBlacklisted>;
9
-
9
+ //#endregion
10
+ //#region src/vector/index.d.ts
10
11
  type ElasticSearchVectorParams = QueryVectorParams<ElasticSearchVectorFilter>;
11
12
  type ElasticSearchAuth = {
12
- apiKey: string;
13
+ apiKey: string;
13
14
  } | {
14
- username: string;
15
- password: string;
15
+ username: string;
16
+ password: string;
16
17
  } | {
17
- bearer: string;
18
+ bearer: string;
18
19
  };
19
20
  type ElasticSearchVectorConfig = {
20
- id: string;
21
- client: Client;
22
- url?: never;
23
- auth?: never;
21
+ id: string;
22
+ client: Client;
23
+ url?: never;
24
+ auth?: never;
24
25
  } | {
25
- id: string;
26
- url: string;
27
- auth?: ElasticSearchAuth;
28
- client?: never;
26
+ id: string;
27
+ url: string;
28
+ auth?: ElasticSearchAuth;
29
+ client?: never;
29
30
  };
30
31
  declare class ElasticSearchVector extends MastraVector<ElasticSearchVectorFilter> {
31
- private client;
32
- /**
33
- * Creates a new ElasticSearchVector client.
34
- *
35
- * Accepts either a pre-configured ElasticSearch client or connection parameters:
36
- * - `{ id, client }` - Use an existing ElasticSearch client
37
- * - `{ id, url, auth? }` - Create a new client from connection parameters
38
- */
39
- constructor(config: ElasticSearchVectorConfig);
40
- /**
41
- * Creates a new collection with the specified configuration.
42
- *
43
- * @param {string} indexName - The name of the collection to create.
44
- * @param {number} dimension - The dimension of the vectors to be stored in the collection.
45
- * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
46
- * @returns {Promise<void>} A promise that resolves when the collection is created.
47
- */
48
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
49
- /**
50
- * Lists all indexes.
51
- *
52
- * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
53
- */
54
- listIndexes(): Promise<string[]>;
55
- /**
56
- * Validates that an existing index matches the requested dimension and metric.
57
- * Throws an error if there's a mismatch, otherwise allows idempotent creation.
58
- */
59
- protected validateExistingIndex(indexName: string, dimension: number, metric: string): Promise<void>;
60
- /**
61
- * Retrieves statistics about a vector index.
62
- *
63
- * @param {string} indexName - The name of the index to describe
64
- * @returns A promise that resolves to the index statistics including dimension, count and metric
65
- */
66
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
67
- /**
68
- * Deletes the specified index.
69
- *
70
- * @param {string} indexName - The name of the index to delete.
71
- * @returns {Promise<void>} A promise that resolves when the index is deleted.
72
- */
73
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
74
- /**
75
- * Inserts or updates vectors in the specified collection.
76
- *
77
- * @param {string} indexName - The name of the collection to upsert into.
78
- * @param {number[][]} vectors - An array of vectors to upsert.
79
- * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
80
- * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
81
- * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
82
- */
83
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
84
- /**
85
- * Queries the specified collection using a vector and optional filter.
86
- *
87
- * @param {string} indexName - The name of the collection to query.
88
- * @param {number[]} queryVector - The vector to query with.
89
- * @param {number} [topK] - The maximum number of results to return.
90
- * @param {Record<string, any>} [filter] - An optional filter to apply to the query.
91
- * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
92
- * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
93
- */
94
- query({ indexName, queryVector, filter, topK, includeVector, }: ElasticSearchVectorParams): Promise<QueryResult[]>;
95
- /**
96
- * Validates the dimensions of the vectors.
97
- *
98
- * @param {number[][]} vectors - The vectors to validate.
99
- * @param {number} dimension - The dimension of the vectors.
100
- * @returns {void}
101
- */
102
- private validateVectorDimensions;
103
- /**
104
- * Transforms the filter to the ElasticSearch DSL.
105
- *
106
- * @param {ElasticSearchVectorFilter} filter - The filter to transform.
107
- * @returns {Record<string, any>} The transformed filter.
108
- */
109
- private transformFilter;
110
- /**
111
- * Updates vectors by ID or filter with the provided vector and/or metadata.
112
- * @param params - Parameters containing either id or filter for targeting vectors to update
113
- * @param params.indexName - The name of the index containing the vector(s).
114
- * @param params.id - The ID of a single vector to update (mutually exclusive with filter).
115
- * @param params.filter - A filter to match multiple vectors to update (mutually exclusive with id).
116
- * @param params.update - An object containing the vector and/or metadata to update.
117
- * @returns A promise that resolves when the update is complete.
118
- * @throws Will throw an error if no updates are provided or if the update operation fails.
119
- */
120
- updateVector(params: UpdateVectorParams<ElasticSearchVectorFilter>): Promise<void>;
121
- /**
122
- * Updates a single vector by its ID.
123
- */
124
- private updateVectorById;
125
- /**
126
- * Updates multiple vectors matching a filter.
127
- */
128
- private updateVectorsByFilter;
129
- /**
130
- * Deletes a vector by its ID.
131
- * @param indexName - The name of the index containing the vector.
132
- * @param id - The ID of the vector to delete.
133
- * @returns A promise that resolves when the deletion is complete.
134
- * @throws Will throw an error if the deletion operation fails.
135
- */
136
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
137
- deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ElasticSearchVectorFilter>): Promise<void>;
32
+ private client;
33
+ /**
34
+ * Creates a new ElasticSearchVector client.
35
+ *
36
+ * Accepts either a pre-configured ElasticSearch client or connection parameters:
37
+ * - `{ id, client }` - Use an existing ElasticSearch client
38
+ * - `{ id, url, auth? }` - Create a new client from connection parameters
39
+ */
40
+ constructor(config: ElasticSearchVectorConfig);
41
+ /**
42
+ * Creates a new collection with the specified configuration.
43
+ *
44
+ * @param {string} indexName - The name of the collection to create.
45
+ * @param {number} dimension - The dimension of the vectors to be stored in the collection.
46
+ * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
47
+ * @returns {Promise<void>} A promise that resolves when the collection is created.
48
+ */
49
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
50
+ /**
51
+ * Lists all indexes.
52
+ *
53
+ * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
54
+ */
55
+ listIndexes(): Promise<string[]>;
56
+ /**
57
+ * Validates that an existing index matches the requested dimension and metric.
58
+ * Throws an error if there's a mismatch, otherwise allows idempotent creation.
59
+ */
60
+ protected validateExistingIndex(indexName: string, dimension: number, metric: string): Promise<void>;
61
+ /**
62
+ * Retrieves statistics about a vector index.
63
+ *
64
+ * @param {string} indexName - The name of the index to describe
65
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
66
+ */
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ /**
69
+ * Deletes the specified index.
70
+ *
71
+ * @param {string} indexName - The name of the index to delete.
72
+ * @returns {Promise<void>} A promise that resolves when the index is deleted.
73
+ */
74
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
75
+ /**
76
+ * Inserts or updates vectors in the specified collection.
77
+ *
78
+ * @param {string} indexName - The name of the collection to upsert into.
79
+ * @param {number[][]} vectors - An array of vectors to upsert.
80
+ * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
81
+ * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
82
+ * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
83
+ */
84
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
85
+ /**
86
+ * Queries the specified collection using a vector and optional filter.
87
+ *
88
+ * @param {string} indexName - The name of the collection to query.
89
+ * @param {number[]} queryVector - The vector to query with.
90
+ * @param {number} [topK] - The maximum number of results to return.
91
+ * @param {Record<string, any>} [filter] - An optional filter to apply to the query.
92
+ * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
93
+ * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
94
+ */
95
+ query({ indexName, queryVector, filter, topK, includeVector }: ElasticSearchVectorParams): Promise<QueryResult[]>;
96
+ /**
97
+ * Validates the dimensions of the vectors.
98
+ *
99
+ * @param {number[][]} vectors - The vectors to validate.
100
+ * @param {number} dimension - The dimension of the vectors.
101
+ * @returns {void}
102
+ */
103
+ private validateVectorDimensions;
104
+ /**
105
+ * Transforms the filter to the ElasticSearch DSL.
106
+ *
107
+ * @param {ElasticSearchVectorFilter} filter - The filter to transform.
108
+ * @returns {Record<string, any>} The transformed filter.
109
+ */
110
+ private transformFilter;
111
+ /**
112
+ * Updates vectors by ID or filter with the provided vector and/or metadata.
113
+ * @param params - Parameters containing either id or filter for targeting vectors to update
114
+ * @param params.indexName - The name of the index containing the vector(s).
115
+ * @param params.id - The ID of a single vector to update (mutually exclusive with filter).
116
+ * @param params.filter - A filter to match multiple vectors to update (mutually exclusive with id).
117
+ * @param params.update - An object containing the vector and/or metadata to update.
118
+ * @returns A promise that resolves when the update is complete.
119
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
120
+ */
121
+ updateVector(params: UpdateVectorParams<ElasticSearchVectorFilter>): Promise<void>;
122
+ /**
123
+ * Updates a single vector by its ID.
124
+ */
125
+ private updateVectorById;
126
+ /**
127
+ * Updates multiple vectors matching a filter.
128
+ */
129
+ private updateVectorsByFilter;
130
+ /**
131
+ * Deletes a vector by its ID.
132
+ * @param indexName - The name of the index containing the vector.
133
+ * @param id - The ID of the vector to delete.
134
+ * @returns A promise that resolves when the deletion is complete.
135
+ * @throws Will throw an error if the deletion operation fails.
136
+ */
137
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
138
+ deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ElasticSearchVectorFilter>): Promise<void>;
138
139
  }
139
-
140
+ //#endregion
140
141
  export { type ElasticSearchAuth, ElasticSearchVector, type ElasticSearchVectorConfig, type ElasticSearchVectorFilter };
142
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/vector/filter.ts","../src/vector/index.ts"],"mappings":";;;;KAUK,gCAAgC,KAAK;KAErC,uCAAuC,KAAK;KAE5C,2BAA2B;KAEpB,4BAA4B,mBAChC,+BACN,+BACA,sCACA;;;KCaG,4BAA4B,kBAAkB;KAEvC;EAAsB;;EAAqB;EAAkB;;EAAuB;;KAEpF;EACN;EAAY,QAAQ;EAAqB;EAAa;;EACtD;EAAY;EAAa,OAAO;EAAmB;;cAE5C,4BAA4B,aAAa;UAC5C;;;;;;;;EASI,YAAA,QAAQ;;;;;;;;;EA6Bd,cAAc,WAAW,WAAW,UAAqB,oBAAoB;;;;;;EAkD7E,eAAe;;;;;YAwBL,sBAAsB,mBAAmB,mBAAmB,iBAAiB;;;;;;;EAoDvF,gBAAgB,aAAa,sBAAsB,QAAQ;;;;;;;EAqB3D,cAAc,aAAa,oBAAoB;;;;;;;;;;EA4B/C,SAAS,WAAW,SAAS,UAAe,OAAO,qBAAqB;;;;;;;;;;;EA+HxE,QACJ,WACA,aACA,QACA,MACA,iBACC,4BAA4B,QAAQ;;;;;;;;UA+D/B;;;;;;;UAYA;;;;;;;;;;;EAeF,aAAa,QAAQ,mBAAmB,6BAA6B;;;;UAwD7D;;;;UAuFA;;;;;;;;EAyDR,eAAe,WAAW,MAAM,qBAAqB;EA2BrD,gBAAgB,WAAW,QAAQ,OAAO,oBAAoB,6BAA6B"}
package/dist/index.d.ts CHANGED
@@ -1,140 +1,142 @@
1
- import { Client } from '@elastic/elasticsearch';
2
- import { MastraVector, CreateIndexParams, DescribeIndexParams, IndexStats, DeleteIndexParams, UpsertVectorParams, QueryVectorParams, QueryResult, UpdateVectorParams, DeleteVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
3
- import { VectorFilter, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
4
-
1
+ import { Client } from "@elastic/elasticsearch";
2
+ import { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DeleteVectorsParams, DescribeIndexParams, IndexStats, MastraVector, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams } from "@mastra/core/vector";
3
+ import { BaseFilterTranslator, BlacklistedRootOperators, LogicalOperatorValueMap, OperatorValueMap, VectorFilter } from "@mastra/core/vector/filter";
4
+ //#region src/vector/filter.d.ts
5
5
  type ElasticSearchOperatorValueMap = Omit<OperatorValueMap, '$options' | '$nor' | '$elemMatch'>;
6
6
  type ElasticSearchLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;
7
7
  type ElasticSearchBlacklisted = BlacklistedRootOperators | '$nor';
8
8
  type ElasticSearchVectorFilter = VectorFilter<keyof ElasticSearchOperatorValueMap, ElasticSearchOperatorValueMap, ElasticSearchLogicalOperatorValueMap, ElasticSearchBlacklisted>;
9
-
9
+ //#endregion
10
+ //#region src/vector/index.d.ts
10
11
  type ElasticSearchVectorParams = QueryVectorParams<ElasticSearchVectorFilter>;
11
12
  type ElasticSearchAuth = {
12
- apiKey: string;
13
+ apiKey: string;
13
14
  } | {
14
- username: string;
15
- password: string;
15
+ username: string;
16
+ password: string;
16
17
  } | {
17
- bearer: string;
18
+ bearer: string;
18
19
  };
19
20
  type ElasticSearchVectorConfig = {
20
- id: string;
21
- client: Client;
22
- url?: never;
23
- auth?: never;
21
+ id: string;
22
+ client: Client;
23
+ url?: never;
24
+ auth?: never;
24
25
  } | {
25
- id: string;
26
- url: string;
27
- auth?: ElasticSearchAuth;
28
- client?: never;
26
+ id: string;
27
+ url: string;
28
+ auth?: ElasticSearchAuth;
29
+ client?: never;
29
30
  };
30
31
  declare class ElasticSearchVector extends MastraVector<ElasticSearchVectorFilter> {
31
- private client;
32
- /**
33
- * Creates a new ElasticSearchVector client.
34
- *
35
- * Accepts either a pre-configured ElasticSearch client or connection parameters:
36
- * - `{ id, client }` - Use an existing ElasticSearch client
37
- * - `{ id, url, auth? }` - Create a new client from connection parameters
38
- */
39
- constructor(config: ElasticSearchVectorConfig);
40
- /**
41
- * Creates a new collection with the specified configuration.
42
- *
43
- * @param {string} indexName - The name of the collection to create.
44
- * @param {number} dimension - The dimension of the vectors to be stored in the collection.
45
- * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
46
- * @returns {Promise<void>} A promise that resolves when the collection is created.
47
- */
48
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
49
- /**
50
- * Lists all indexes.
51
- *
52
- * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
53
- */
54
- listIndexes(): Promise<string[]>;
55
- /**
56
- * Validates that an existing index matches the requested dimension and metric.
57
- * Throws an error if there's a mismatch, otherwise allows idempotent creation.
58
- */
59
- protected validateExistingIndex(indexName: string, dimension: number, metric: string): Promise<void>;
60
- /**
61
- * Retrieves statistics about a vector index.
62
- *
63
- * @param {string} indexName - The name of the index to describe
64
- * @returns A promise that resolves to the index statistics including dimension, count and metric
65
- */
66
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
67
- /**
68
- * Deletes the specified index.
69
- *
70
- * @param {string} indexName - The name of the index to delete.
71
- * @returns {Promise<void>} A promise that resolves when the index is deleted.
72
- */
73
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
74
- /**
75
- * Inserts or updates vectors in the specified collection.
76
- *
77
- * @param {string} indexName - The name of the collection to upsert into.
78
- * @param {number[][]} vectors - An array of vectors to upsert.
79
- * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
80
- * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
81
- * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
82
- */
83
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
84
- /**
85
- * Queries the specified collection using a vector and optional filter.
86
- *
87
- * @param {string} indexName - The name of the collection to query.
88
- * @param {number[]} queryVector - The vector to query with.
89
- * @param {number} [topK] - The maximum number of results to return.
90
- * @param {Record<string, any>} [filter] - An optional filter to apply to the query.
91
- * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
92
- * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
93
- */
94
- query({ indexName, queryVector, filter, topK, includeVector, }: ElasticSearchVectorParams): Promise<QueryResult[]>;
95
- /**
96
- * Validates the dimensions of the vectors.
97
- *
98
- * @param {number[][]} vectors - The vectors to validate.
99
- * @param {number} dimension - The dimension of the vectors.
100
- * @returns {void}
101
- */
102
- private validateVectorDimensions;
103
- /**
104
- * Transforms the filter to the ElasticSearch DSL.
105
- *
106
- * @param {ElasticSearchVectorFilter} filter - The filter to transform.
107
- * @returns {Record<string, any>} The transformed filter.
108
- */
109
- private transformFilter;
110
- /**
111
- * Updates vectors by ID or filter with the provided vector and/or metadata.
112
- * @param params - Parameters containing either id or filter for targeting vectors to update
113
- * @param params.indexName - The name of the index containing the vector(s).
114
- * @param params.id - The ID of a single vector to update (mutually exclusive with filter).
115
- * @param params.filter - A filter to match multiple vectors to update (mutually exclusive with id).
116
- * @param params.update - An object containing the vector and/or metadata to update.
117
- * @returns A promise that resolves when the update is complete.
118
- * @throws Will throw an error if no updates are provided or if the update operation fails.
119
- */
120
- updateVector(params: UpdateVectorParams<ElasticSearchVectorFilter>): Promise<void>;
121
- /**
122
- * Updates a single vector by its ID.
123
- */
124
- private updateVectorById;
125
- /**
126
- * Updates multiple vectors matching a filter.
127
- */
128
- private updateVectorsByFilter;
129
- /**
130
- * Deletes a vector by its ID.
131
- * @param indexName - The name of the index containing the vector.
132
- * @param id - The ID of the vector to delete.
133
- * @returns A promise that resolves when the deletion is complete.
134
- * @throws Will throw an error if the deletion operation fails.
135
- */
136
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
137
- deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ElasticSearchVectorFilter>): Promise<void>;
32
+ private client;
33
+ /**
34
+ * Creates a new ElasticSearchVector client.
35
+ *
36
+ * Accepts either a pre-configured ElasticSearch client or connection parameters:
37
+ * - `{ id, client }` - Use an existing ElasticSearch client
38
+ * - `{ id, url, auth? }` - Create a new client from connection parameters
39
+ */
40
+ constructor(config: ElasticSearchVectorConfig);
41
+ /**
42
+ * Creates a new collection with the specified configuration.
43
+ *
44
+ * @param {string} indexName - The name of the collection to create.
45
+ * @param {number} dimension - The dimension of the vectors to be stored in the collection.
46
+ * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
47
+ * @returns {Promise<void>} A promise that resolves when the collection is created.
48
+ */
49
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
50
+ /**
51
+ * Lists all indexes.
52
+ *
53
+ * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
54
+ */
55
+ listIndexes(): Promise<string[]>;
56
+ /**
57
+ * Validates that an existing index matches the requested dimension and metric.
58
+ * Throws an error if there's a mismatch, otherwise allows idempotent creation.
59
+ */
60
+ protected validateExistingIndex(indexName: string, dimension: number, metric: string): Promise<void>;
61
+ /**
62
+ * Retrieves statistics about a vector index.
63
+ *
64
+ * @param {string} indexName - The name of the index to describe
65
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
66
+ */
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ /**
69
+ * Deletes the specified index.
70
+ *
71
+ * @param {string} indexName - The name of the index to delete.
72
+ * @returns {Promise<void>} A promise that resolves when the index is deleted.
73
+ */
74
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
75
+ /**
76
+ * Inserts or updates vectors in the specified collection.
77
+ *
78
+ * @param {string} indexName - The name of the collection to upsert into.
79
+ * @param {number[][]} vectors - An array of vectors to upsert.
80
+ * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
81
+ * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
82
+ * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
83
+ */
84
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
85
+ /**
86
+ * Queries the specified collection using a vector and optional filter.
87
+ *
88
+ * @param {string} indexName - The name of the collection to query.
89
+ * @param {number[]} queryVector - The vector to query with.
90
+ * @param {number} [topK] - The maximum number of results to return.
91
+ * @param {Record<string, any>} [filter] - An optional filter to apply to the query.
92
+ * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
93
+ * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
94
+ */
95
+ query({ indexName, queryVector, filter, topK, includeVector }: ElasticSearchVectorParams): Promise<QueryResult[]>;
96
+ /**
97
+ * Validates the dimensions of the vectors.
98
+ *
99
+ * @param {number[][]} vectors - The vectors to validate.
100
+ * @param {number} dimension - The dimension of the vectors.
101
+ * @returns {void}
102
+ */
103
+ private validateVectorDimensions;
104
+ /**
105
+ * Transforms the filter to the ElasticSearch DSL.
106
+ *
107
+ * @param {ElasticSearchVectorFilter} filter - The filter to transform.
108
+ * @returns {Record<string, any>} The transformed filter.
109
+ */
110
+ private transformFilter;
111
+ /**
112
+ * Updates vectors by ID or filter with the provided vector and/or metadata.
113
+ * @param params - Parameters containing either id or filter for targeting vectors to update
114
+ * @param params.indexName - The name of the index containing the vector(s).
115
+ * @param params.id - The ID of a single vector to update (mutually exclusive with filter).
116
+ * @param params.filter - A filter to match multiple vectors to update (mutually exclusive with id).
117
+ * @param params.update - An object containing the vector and/or metadata to update.
118
+ * @returns A promise that resolves when the update is complete.
119
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
120
+ */
121
+ updateVector(params: UpdateVectorParams<ElasticSearchVectorFilter>): Promise<void>;
122
+ /**
123
+ * Updates a single vector by its ID.
124
+ */
125
+ private updateVectorById;
126
+ /**
127
+ * Updates multiple vectors matching a filter.
128
+ */
129
+ private updateVectorsByFilter;
130
+ /**
131
+ * Deletes a vector by its ID.
132
+ * @param indexName - The name of the index containing the vector.
133
+ * @param id - The ID of the vector to delete.
134
+ * @returns A promise that resolves when the deletion is complete.
135
+ * @throws Will throw an error if the deletion operation fails.
136
+ */
137
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
138
+ deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ElasticSearchVectorFilter>): Promise<void>;
138
139
  }
139
-
140
+ //#endregion
140
141
  export { type ElasticSearchAuth, ElasticSearchVector, type ElasticSearchVectorConfig, type ElasticSearchVectorFilter };
142
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/vector/filter.ts","../src/vector/index.ts"],"mappings":";;;;KAUK,gCAAgC,KAAK;KAErC,uCAAuC,KAAK;KAE5C,2BAA2B;KAEpB,4BAA4B,mBAChC,+BACN,+BACA,sCACA;;;KCaG,4BAA4B,kBAAkB;KAEvC;EAAsB;;EAAqB;EAAkB;;EAAuB;;KAEpF;EACN;EAAY,QAAQ;EAAqB;EAAa;;EACtD;EAAY;EAAa,OAAO;EAAmB;;cAE5C,4BAA4B,aAAa;UAC5C;;;;;;;;EASI,YAAA,QAAQ;;;;;;;;;EA6Bd,cAAc,WAAW,WAAW,UAAqB,oBAAoB;;;;;;EAkD7E,eAAe;;;;;YAwBL,sBAAsB,mBAAmB,mBAAmB,iBAAiB;;;;;;;EAoDvF,gBAAgB,aAAa,sBAAsB,QAAQ;;;;;;;EAqB3D,cAAc,aAAa,oBAAoB;;;;;;;;;;EA4B/C,SAAS,WAAW,SAAS,UAAe,OAAO,qBAAqB;;;;;;;;;;;EA+HxE,QACJ,WACA,aACA,QACA,MACA,iBACC,4BAA4B,QAAQ;;;;;;;;UA+D/B;;;;;;;UAYA;;;;;;;;;;;EAeF,aAAa,QAAQ,mBAAmB,6BAA6B;;;;UAwD7D;;;;UAuFA;;;;;;;;EAyDR,eAAe,WAAW,MAAM,qBAAqB;EA2BrD,gBAAgB,WAAW,QAAQ,OAAO,oBAAoB,6BAA6B"}