endee 1.0.4-beta.2 → 1.0.6
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 +0 -138
- package/dist/endee.d.ts +2 -2
- package/dist/endee.d.ts.map +1 -1
- package/dist/endee.js +10 -27
- package/dist/endee.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/indexClient.d.ts +1 -3
- package/dist/indexClient.d.ts.map +1 -1
- package/dist/indexClient.js +11 -62
- package/dist/indexClient.js.map +1 -1
- package/dist/types/index.d.ts +6 -16
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@ Endee is a TypeScript client for a vector database designed for maximum speed an
|
|
|
7
7
|
- **TypeScript First**: Full type safety and IntelliSense support
|
|
8
8
|
- **Fast ANN Searches**: Efficient similarity searches on vector data
|
|
9
9
|
- **Multiple Distance Metrics**: Support for cosine, L2, and inner product distance metrics
|
|
10
|
-
- **Hybrid Indexes**: Support for dense vectors, sparse vectors, and hybrid (dense + sparse) searches
|
|
11
10
|
- **Metadata Support**: Attach and search with metadata and filters
|
|
12
11
|
- **Client-Side Encryption**: Optional AES-256 encryption for your metadata
|
|
13
12
|
- **High Performance**: Optimized for speed and efficiency
|
|
@@ -97,7 +96,6 @@ await endee.createIndex({
|
|
|
97
96
|
M: 32, // M: Graph connectivity parameter
|
|
98
97
|
efCon: 256, // efCon: Construction-time parameter
|
|
99
98
|
precision: Precision.INT8D // Quantization precision (default: Precision.INT8D)
|
|
100
|
-
sparseDimension: 1000 // Optional: Enable hybrid index with sparse dimension
|
|
101
99
|
});
|
|
102
100
|
|
|
103
101
|
// Delete an index
|
|
@@ -146,142 +144,6 @@ const description = await index.describe();
|
|
|
146
144
|
console.log(description);
|
|
147
145
|
```
|
|
148
146
|
|
|
149
|
-
## Hybrid Indexes
|
|
150
|
-
|
|
151
|
-
Endee supports **Hybrid Indexes** that combine dense vectors with sparse vectors, enabling powerful search capabilities. Hybrid indexes allow you to:
|
|
152
|
-
|
|
153
|
-
- Store both dense embeddings (e.g., from neural networks) and sparse features (e.g., keyword frequencies, categorical encodings)
|
|
154
|
-
- Perform dense-only searches (traditional vector similarity)
|
|
155
|
-
- Perform sparse-only searches (keyword/feature matching)
|
|
156
|
-
- Perform hybrid searches (combining both dense and sparse signals)
|
|
157
|
-
|
|
158
|
-
### Creating a Hybrid Index
|
|
159
|
-
|
|
160
|
-
To create a hybrid index, specify the `sparseDimension` parameter when creating an index:
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
// Create a hybrid index with dense dimension 384 and sparse dimension 10000
|
|
164
|
-
await endee.createIndex({
|
|
165
|
-
name: "hybrid_index",
|
|
166
|
-
dimension: 384, // Dense vector dimension
|
|
167
|
-
sparseDimension: 10000, // Sparse vector dimension (max index value)
|
|
168
|
-
spaceType: "cosine",
|
|
169
|
-
precision: "medium"
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Get the hybrid index reference
|
|
173
|
-
const index = await endee.getIndex("hybrid_index");
|
|
174
|
-
|
|
175
|
-
// Check if index is hybrid
|
|
176
|
-
const description = index.describe();
|
|
177
|
-
console.log(description.isHybrid); // true
|
|
178
|
-
console.log(description.sparseDimension); // 10000
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Upserting Vectors with Sparse Data
|
|
182
|
-
|
|
183
|
-
When working with a hybrid index, you can insert vectors with both dense and sparse components:
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
// Insert vectors with both dense and sparse components (hybrid index only)
|
|
187
|
-
await index.upsert([
|
|
188
|
-
{
|
|
189
|
-
id: "doc2",
|
|
190
|
-
vector: [0.2, 0.3, 0.4, /* ... 384 dimensions */], // Dense vector
|
|
191
|
-
sparseIndices: [5, 42, 100, 500], // Sparse feature indices
|
|
192
|
-
sparseValues: [0.8, 0.6, 0.9, 0.7], // Sparse feature values
|
|
193
|
-
meta: { title: "Document 2", category: "tech" }
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
id: "doc3",
|
|
197
|
-
vector: [0.3, 0.4, 0.5, /* ... 384 dimensions */],
|
|
198
|
-
sparseIndices: [10, 25, 200],
|
|
199
|
-
sparseValues: [0.5, 0.4, 0.6],
|
|
200
|
-
meta: { title: "Document 3", category: "science" }
|
|
201
|
-
}
|
|
202
|
-
]);
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Important Notes:**
|
|
206
|
-
- `sparseIndices` and `sparseValues` must have the same length
|
|
207
|
-
- Sparse indices must be in the range `[0, sparseDimension)`
|
|
208
|
-
- Both `sparseIndices` and `sparseValues` must be provided together (or both omitted)
|
|
209
|
-
- You cannot insert sparse data into a dense-only index (one created without `sparseDimension`)
|
|
210
|
-
|
|
211
|
-
### Querying Hybrid Indexes
|
|
212
|
-
|
|
213
|
-
Hybrid indexes support three types of searches:
|
|
214
|
-
|
|
215
|
-
#### 1. Dense Search (Traditional Vector Similarity)
|
|
216
|
-
|
|
217
|
-
Search using only the dense vector component:
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
const results = await index.query({
|
|
221
|
-
vector: [0.2, 0.3, 0.4, /* ... 384 dimensions */], // Query dense vector
|
|
222
|
-
topK: 10,
|
|
223
|
-
ef: 128
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Results are ranked by dense vector similarity
|
|
227
|
-
for (const item of results) {
|
|
228
|
-
console.log(`ID: ${item.id}, Similarity: ${item.similarity}`);
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
#### 2. Sparse Search (Keyword/Feature Matching)
|
|
233
|
-
|
|
234
|
-
Search using only the sparse component:
|
|
235
|
-
|
|
236
|
-
```typescript
|
|
237
|
-
const results = await index.query({
|
|
238
|
-
sparseIndices: [5, 42, 100], // Query sparse feature indices
|
|
239
|
-
sparseValues: [0.8, 0.6, 0.9], // Query sparse feature values
|
|
240
|
-
topK: 10,
|
|
241
|
-
ef: 128
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Results are ranked by sparse vector similarity
|
|
245
|
-
for (const item of results) {
|
|
246
|
-
console.log(`ID: ${item.id}, Similarity: ${item.similarity}`);
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
#### 3. Hybrid Search (Combined Dense + Sparse)
|
|
251
|
-
|
|
252
|
-
Search using both dense and sparse components for the most powerful results:
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
const results = await index.query({
|
|
256
|
-
vector: [0.2, 0.3, 0.4, /* ... 384 dimensions */], // Dense query
|
|
257
|
-
sparseIndices: [5, 42, 100], // Sparse query indices
|
|
258
|
-
sparseValues: [0.8, 0.6, 0.9], // Sparse query values
|
|
259
|
-
topK: 10,
|
|
260
|
-
ef: 128
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// Results combine both dense and sparse signals
|
|
264
|
-
for (const item of results) {
|
|
265
|
-
console.log(`ID: ${item.id}, Similarity: ${item.similarity}`);
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Use Cases for Hybrid Indexes
|
|
270
|
-
|
|
271
|
-
Hybrid indexes are ideal for scenarios where you want to combine:
|
|
272
|
-
|
|
273
|
-
- **Semantic similarity** (dense embeddings from transformers) with **keyword matching** (sparse TF-IDF or BM25 features)
|
|
274
|
-
- **Neural embeddings** with **categorical features** or **one-hot encodings**
|
|
275
|
-
- **Content-based recommendations** (dense) with **collaborative filtering signals** (sparse)
|
|
276
|
-
|
|
277
|
-
### Key Points
|
|
278
|
-
|
|
279
|
-
- **Hybrid indexes are optional**: Create them only when you need sparse vector support
|
|
280
|
-
- **Dense-only indexes**: Work with traditional dense vectors only (no sparse support)
|
|
281
|
-
- **Sparse data validation**: The system validates sparse indices are within bounds and arrays match in length
|
|
282
|
-
- **Flexible querying**: You can query with dense only, sparse only, or both on hybrid indexes
|
|
283
|
-
- **Backward compatible**: Dense-only indexes continue to work as before
|
|
284
|
-
|
|
285
147
|
## Filtering
|
|
286
148
|
|
|
287
149
|
Endee supports structured filtering using operators like `$eq`, `$in`, and `$range`. For detailed documentation on filtering, see the [official documentation](https://docs.endee.io/sdks/typescript/usage#filtered-querying).
|
package/dist/endee.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main Endee client for Endee-DB
|
|
3
3
|
*/
|
|
4
|
-
import { Index } from
|
|
5
|
-
import { type CreateIndexOptions } from
|
|
4
|
+
import { Index } from './indexClient.js';
|
|
5
|
+
import { type CreateIndexOptions } from './types/index.js';
|
|
6
6
|
export declare class Endee {
|
|
7
7
|
private token;
|
|
8
8
|
private baseUrl;
|
package/dist/endee.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endee.d.ts","sourceRoot":"","sources":["../src/endee.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"endee.d.ts","sourceRoot":"","sources":["../src/endee.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,kBAAkB,CAAC;AAG1B,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,KAAK,GAAE,MAAM,GAAG,IAAW;IAavC,WAAW,IAAI,MAAM;IAUf,WAAW,CACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC;IA4DZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAgB/B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuB1C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO,CAAC,KAAK,CAAC;CAkCxE"}
|
package/dist/endee.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main Endee client for Endee-DB
|
|
3
3
|
*/
|
|
4
|
-
import axios from
|
|
5
|
-
import crypto from
|
|
6
|
-
import { raiseException } from
|
|
7
|
-
import { Index } from
|
|
8
|
-
import { isValidIndexName } from
|
|
9
|
-
import { Precision } from
|
|
10
|
-
import { getChecksum } from
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import crypto from 'crypto';
|
|
6
|
+
import { raiseException } from './exceptions.js';
|
|
7
|
+
import { Index } from './indexClient.js';
|
|
8
|
+
import { isValidIndexName, } from './utils.js';
|
|
9
|
+
import { Precision } from './types/index.js';
|
|
10
|
+
import { getChecksum } from './crypto.js';
|
|
11
11
|
export class Endee {
|
|
12
12
|
token;
|
|
13
13
|
baseUrl;
|
|
@@ -26,21 +26,18 @@ export class Endee {
|
|
|
26
26
|
}
|
|
27
27
|
generateKey() {
|
|
28
28
|
// Generate a random hex key of 32 bytes (256 bit)
|
|
29
|
-
const key = crypto.randomBytes(32).toString(
|
|
29
|
+
const key = crypto.randomBytes(32).toString('hex');
|
|
30
30
|
console.log("Store this encryption key in a secure location. Loss of the key will result in the irreversible loss of associated vector data.\nKey: ", key);
|
|
31
31
|
return key;
|
|
32
32
|
}
|
|
33
33
|
async createIndex(options) {
|
|
34
|
-
const { name, dimension, spaceType =
|
|
34
|
+
const { name, dimension, spaceType = 'cosine', M = 16, efCon = 128, key = null, precision = Precision.INT8D, version = null, } = options;
|
|
35
35
|
if (!isValidIndexName(name)) {
|
|
36
36
|
throw new Error("Invalid index name. Index name must be alphanumeric and can contain underscores and less than 48 characters");
|
|
37
37
|
}
|
|
38
38
|
if (dimension > 10000) {
|
|
39
39
|
throw new Error("Dimension cannot be greater than 10000");
|
|
40
40
|
}
|
|
41
|
-
if (sparseDimension && sparseDimension < 0) {
|
|
42
|
-
throw new Error("Sparse dimension cannot be less than 0");
|
|
43
|
-
}
|
|
44
41
|
const normalizedSpaceType = spaceType.toLowerCase();
|
|
45
42
|
if (!["cosine", "l2", "ip"].includes(normalizedSpaceType)) {
|
|
46
43
|
throw new Error(`Invalid space type: ${spaceType}`);
|
|
@@ -59,9 +56,6 @@ export class Endee {
|
|
|
59
56
|
precision: precision,
|
|
60
57
|
version: version,
|
|
61
58
|
};
|
|
62
|
-
if (sparseDimension) {
|
|
63
|
-
data.sparse_dim = sparseDimension;
|
|
64
|
-
}
|
|
65
59
|
if (version !== undefined) {
|
|
66
60
|
data.version = version;
|
|
67
61
|
}
|
|
@@ -141,23 +135,12 @@ export class Endee {
|
|
|
141
135
|
throw err;
|
|
142
136
|
}
|
|
143
137
|
const data = response.data;
|
|
144
|
-
const indexInfo = {
|
|
145
|
-
name: data.index_name,
|
|
146
|
-
spaceType: data.space_type,
|
|
147
|
-
dimension: data.dimension,
|
|
148
|
-
total_elements: data.total_elements,
|
|
149
|
-
precision: data.precision,
|
|
150
|
-
M: data.M,
|
|
151
|
-
checksum: data.checksum,
|
|
152
|
-
version: data.version,
|
|
153
|
-
sparseDimension: data.sparse_dim,
|
|
154
|
-
};
|
|
155
138
|
// Raise error if checksum does not match
|
|
156
139
|
const checksum = getChecksum(key);
|
|
157
140
|
if (checksum !== data.checksum) {
|
|
158
141
|
raiseException(403, "Checksum does not match. Please check the key.");
|
|
159
142
|
}
|
|
160
|
-
const idx = new Index(name, key, this.token, this.baseUrl, this.version,
|
|
143
|
+
const idx = new Index(name, key, this.token, this.baseUrl, this.version, data);
|
|
161
144
|
return idx;
|
|
162
145
|
}
|
|
163
146
|
}
|
package/dist/endee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endee.js","sourceRoot":"","sources":["../src/endee.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,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nC,CAAC;QACF,IAAI,QAAQ,CAAC;QACb,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,UAAU,IAAI,OAAO,EAAE;gBAC/D,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAC5C,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACzD,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAiB,CAAC;QAExC,yCAAyC;QACzC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC/B,cAAc,CAAC,GAAG,EAAE,gDAAgD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,IAAI,EACJ,GAAG,EACH,IAAI,CAAC,KAAM,EACX,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,OAAO,EACZ,IAAI,CACL,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main export file for Endee-DB
|
|
3
3
|
*/
|
|
4
|
-
export { Endee } from
|
|
5
|
-
export { Index } from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
4
|
+
export { Endee } from './endee.js';
|
|
5
|
+
export { Index } from './indexClient.js';
|
|
6
|
+
export * from './exceptions.js';
|
|
7
|
+
export * from './types/index.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main export file for Endee-DB
|
|
3
3
|
*/
|
|
4
|
-
export { Endee } from
|
|
5
|
-
export { Index } from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
4
|
+
export { Endee } from './endee.js';
|
|
5
|
+
export { Index } from './indexClient.js';
|
|
6
|
+
export * from './exceptions.js';
|
|
7
|
+
export * from './types/index.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/indexClient.d.ts
CHANGED
|
@@ -8,14 +8,12 @@ export declare class Index {
|
|
|
8
8
|
private token;
|
|
9
9
|
private url;
|
|
10
10
|
private count;
|
|
11
|
-
private
|
|
11
|
+
private space_type;
|
|
12
12
|
private dimension;
|
|
13
13
|
private precision;
|
|
14
14
|
private M;
|
|
15
|
-
private sparseDimension;
|
|
16
15
|
constructor(name: string, key: string | null, token: string, url: string, _version?: number, params?: Partial<IndexInfo>);
|
|
17
16
|
toString(): string;
|
|
18
|
-
private isHybrid;
|
|
19
17
|
private _normalizeVector;
|
|
20
18
|
upsert(inputArray: VectorItem[]): Promise<string>;
|
|
21
19
|
query(options: QueryOptions): Promise<QueryResult[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexClient.d.ts","sourceRoot":"","sources":["../src/indexClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,gBAAgB,EAGjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,KAAK;IAChB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAgB;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"indexClient.d.ts","sourceRoot":"","sources":["../src/indexClient.ts"],"names":[],"mappings":"AAAA;;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
package/dist/indexClient.js
CHANGED
|
@@ -12,34 +12,29 @@ export class Index {
|
|
|
12
12
|
token;
|
|
13
13
|
url;
|
|
14
14
|
count;
|
|
15
|
-
|
|
15
|
+
space_type;
|
|
16
16
|
dimension;
|
|
17
17
|
precision;
|
|
18
18
|
M;
|
|
19
|
-
sparseDimension;
|
|
20
19
|
constructor(name, key, token, url, _version = 1, params = {}) {
|
|
21
20
|
this.name = name;
|
|
22
21
|
this.key = key;
|
|
23
22
|
this.token = token;
|
|
24
23
|
this.url = url;
|
|
25
24
|
this.count = params.total_elements || 0;
|
|
26
|
-
this.
|
|
25
|
+
this.space_type = params.space_type || "cosine";
|
|
27
26
|
this.dimension = params.dimension || 0;
|
|
28
27
|
this.precision = params.precision || Precision.INT8D;
|
|
29
28
|
this.M = params.M || 16;
|
|
30
|
-
this.sparseDimension = params.sparseDimension || 0;
|
|
31
29
|
}
|
|
32
30
|
toString() {
|
|
33
31
|
return this.name;
|
|
34
32
|
}
|
|
35
|
-
isHybrid() {
|
|
36
|
-
return this.sparseDimension > 0;
|
|
37
|
-
}
|
|
38
33
|
_normalizeVector(vector) {
|
|
39
34
|
if (vector.length !== this.dimension) {
|
|
40
35
|
throw new Error(`Vector dimension mismatch: expected ${this.dimension}, got ${vector.length}`);
|
|
41
36
|
}
|
|
42
|
-
if (this.
|
|
37
|
+
if (this.space_type !== "cosine") {
|
|
43
38
|
return [vector, 1.0];
|
|
44
39
|
}
|
|
45
40
|
const norm = Math.sqrt(vector.reduce((sum, v) => sum + v * v, 0));
|
|
@@ -56,25 +51,6 @@ export class Index {
|
|
|
56
51
|
for (const item of inputArray) {
|
|
57
52
|
const [vector, norm] = this._normalizeVector(item.vector);
|
|
58
53
|
const metaData = jsonZip(item.meta || {}, this.key);
|
|
59
|
-
const sparseIndices = item.sparseIndices || [];
|
|
60
|
-
const sparseValues = item.sparseValues || [];
|
|
61
|
-
if (!this.isHybrid() &&
|
|
62
|
-
(sparseIndices.length > 0 || sparseValues.length > 0)) {
|
|
63
|
-
throw new Error("Cannot insert sparse data into a dense-only index. Create index with sparseDimension > 0 for hybrid support.");
|
|
64
|
-
}
|
|
65
|
-
if (this.isHybrid()) {
|
|
66
|
-
if (sparseIndices.length == 0 || sparseValues.length == 0) {
|
|
67
|
-
throw new Error("Both sparse_indices and sparse_values must be provided for hybrid vectors.");
|
|
68
|
-
}
|
|
69
|
-
if (sparseIndices.length !== sparseValues.length) {
|
|
70
|
-
throw new Error(`sparseIndices and sparseValues must have the same length. Got ${sparseIndices.length} length indices and ${sparseValues.length} length values.`);
|
|
71
|
-
}
|
|
72
|
-
for (const idx of sparseIndices) {
|
|
73
|
-
if (idx < 0 || idx >= this.sparseDimension) {
|
|
74
|
-
throw new Error(`Sparse index ${idx} is out of bounds. Must be in range [0,${this.sparseDimension}).`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
54
|
const vectorObj = [
|
|
79
55
|
String(item.id || ""),
|
|
80
56
|
metaData,
|
|
@@ -82,9 +58,6 @@ export class Index {
|
|
|
82
58
|
norm,
|
|
83
59
|
vector,
|
|
84
60
|
];
|
|
85
|
-
if (this.isHybrid()) {
|
|
86
|
-
vectorObj.push(sparseIndices, sparseValues);
|
|
87
|
-
}
|
|
88
61
|
vectorBatch.push(vectorObj);
|
|
89
62
|
}
|
|
90
63
|
const serializedData = encode(vectorBatch);
|
|
@@ -104,46 +77,24 @@ export class Index {
|
|
|
104
77
|
return "Vectors inserted successfully";
|
|
105
78
|
}
|
|
106
79
|
async query(options) {
|
|
107
|
-
const { vector
|
|
108
|
-
if (
|
|
109
|
-
throw new Error("
|
|
80
|
+
const { vector, topK = 10, filter = null, ef = 128, includeVectors = false, } = options;
|
|
81
|
+
if (!vector)
|
|
82
|
+
throw new Error("vector is required");
|
|
83
|
+
if (topK > 200)
|
|
84
|
+
throw new Error("top_k cannot be greater than 200");
|
|
110
85
|
if (ef > 1024)
|
|
111
86
|
throw new Error("ef search cannot be greater than 1024");
|
|
112
|
-
const
|
|
113
|
-
sparseIndices.length > 0 &&
|
|
114
|
-
sparseValues &&
|
|
115
|
-
sparseIndices.length > 0;
|
|
116
|
-
var hasDense = false;
|
|
117
|
-
if (vector)
|
|
118
|
-
hasDense = true;
|
|
119
|
-
if (!hasDense && !hasSparse) {
|
|
120
|
-
throw new Error("At least one of 'vector' or 'sparseIndices'/'sparseValues' must be provided.");
|
|
121
|
-
}
|
|
122
|
-
if (hasSparse && !this.isHybrid()) {
|
|
123
|
-
throw new Error("Cannot perform sparse search on a dense-only index. Create index with sparseDimension > 0 for hybrid support.");
|
|
124
|
-
}
|
|
125
|
-
if (hasSparse) {
|
|
126
|
-
if (sparseIndices.length != sparseValues.length) {
|
|
127
|
-
throw new Error(`sparseIndices and sparseValues must have the same length. Got ${sparseIndices.length} length indices and ${sparseValues.length} length values.`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
87
|
+
const [queryVector] = this._normalizeVector(vector);
|
|
130
88
|
const headers = {
|
|
131
89
|
Authorization: this.token,
|
|
132
90
|
"Content-Type": "application/json",
|
|
133
91
|
};
|
|
134
92
|
const data = {
|
|
93
|
+
vector: queryVector,
|
|
135
94
|
k: topK,
|
|
136
95
|
ef: ef,
|
|
137
96
|
include_vectors: includeVectors,
|
|
138
97
|
};
|
|
139
|
-
if (vector) {
|
|
140
|
-
const [queryVector] = this._normalizeVector(vector);
|
|
141
|
-
data.vector = queryVector;
|
|
142
|
-
}
|
|
143
|
-
if (hasSparse) {
|
|
144
|
-
data.sparse_indices = sparseIndices;
|
|
145
|
-
data.sparse_values = sparseValues;
|
|
146
|
-
}
|
|
147
98
|
if (filter) {
|
|
148
99
|
data.filter = JSON.stringify(filter);
|
|
149
100
|
}
|
|
@@ -255,10 +206,8 @@ export class Index {
|
|
|
255
206
|
describe() {
|
|
256
207
|
return {
|
|
257
208
|
name: this.name,
|
|
258
|
-
|
|
209
|
+
space_type: this.space_type,
|
|
259
210
|
dimension: this.dimension,
|
|
260
|
-
sparseDimension: this.sparseDimension,
|
|
261
|
-
isHybrid: this.isHybrid(),
|
|
262
211
|
count: this.count,
|
|
263
212
|
precision: this.precision,
|
|
264
213
|
M: this.M,
|
package/dist/indexClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexClient.js","sourceRoot":"","sources":["../src/indexClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAOL,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,KAAK;IACR,IAAI,CAAS;IACb,GAAG,CAAgB;IACnB,KAAK,CAAS;IACd,GAAG,CAAS;IACZ,KAAK,CAAS;IACd,
|
|
1
|
+
{"version":3,"file":"indexClient.js","sourceRoot":"","sources":["../src/indexClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAOL,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,KAAK;IACR,IAAI,CAAS;IACb,GAAG,CAAgB;IACnB,KAAK,CAAS;IACd,GAAG,CAAS;IACZ,KAAK,CAAS;IACd,UAAU,CAAY;IACtB,SAAS,CAAS;IAClB,SAAS,CAAY;IACrB,CAAC,CAAS;IAElB,YACE,IAAY,EACZ,GAAkB,EAClB,KAAa,EACb,GAAW,EACX,QAAQ,GAAG,CAAC,EACZ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GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACzD,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAMrD,CAAC;QAEF,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAExC,OAAO;YACL,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;YAChB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;YACpB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,CAAC,EAAE,IAAI,CAAC,CAAC;SACV,CAAC;IACJ,CAAC;CACF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for Endee-DB
|
|
3
3
|
*/
|
|
4
|
-
export type SpaceType =
|
|
4
|
+
export type SpaceType = 'cosine' | 'l2' | 'ip';
|
|
5
5
|
export declare enum Precision {
|
|
6
6
|
BINARY = "binary",
|
|
7
7
|
INT8D = "int8d",
|
|
@@ -18,25 +18,19 @@ export interface CreateIndexOptions {
|
|
|
18
18
|
precision?: Precision;
|
|
19
19
|
efCon?: number;
|
|
20
20
|
version?: number;
|
|
21
|
-
sparseDimension?: number;
|
|
22
21
|
}
|
|
23
22
|
export interface VectorItem {
|
|
24
23
|
id: string;
|
|
25
24
|
vector: number[];
|
|
26
|
-
sparseIndices?: number[];
|
|
27
|
-
sparseValues?: number[];
|
|
28
25
|
meta?: Record<string, unknown>;
|
|
29
26
|
filter?: Record<string, unknown>;
|
|
30
27
|
}
|
|
31
28
|
export interface QueryOptions {
|
|
32
|
-
vector
|
|
29
|
+
vector: number[];
|
|
33
30
|
topK: number;
|
|
34
31
|
filter?: Array<Record<string, unknown>> | null;
|
|
35
32
|
ef?: number;
|
|
36
33
|
includeVectors?: boolean;
|
|
37
|
-
log?: boolean;
|
|
38
|
-
sparseIndices?: number[];
|
|
39
|
-
sparseValues?: number[];
|
|
40
34
|
}
|
|
41
35
|
export interface QueryResult {
|
|
42
36
|
id: string;
|
|
@@ -49,24 +43,20 @@ export interface QueryResult {
|
|
|
49
43
|
}
|
|
50
44
|
export interface IndexInfo {
|
|
51
45
|
name: string;
|
|
52
|
-
|
|
46
|
+
space_type: SpaceType;
|
|
53
47
|
dimension: number;
|
|
54
48
|
total_elements?: number;
|
|
55
|
-
precision
|
|
49
|
+
precision: Precision;
|
|
56
50
|
M?: number;
|
|
57
51
|
checksum?: Number;
|
|
58
|
-
|
|
59
|
-
version?: number;
|
|
60
|
-
sparseDimension?: number;
|
|
52
|
+
lib_token?: string;
|
|
61
53
|
}
|
|
62
54
|
export interface IndexDescription {
|
|
63
55
|
name: string;
|
|
64
|
-
|
|
56
|
+
space_type: SpaceType;
|
|
65
57
|
dimension: number;
|
|
66
|
-
isHybrid: boolean;
|
|
67
58
|
count: number;
|
|
68
59
|
precision: Precision;
|
|
69
60
|
M: number;
|
|
70
|
-
sparseDimension?: number;
|
|
71
61
|
}
|
|
72
62
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS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