Skip to content

Commit 14976c2

Browse files
authored
Merge pull request #6 from endee-io/dev
Dev
2 parents 7480ac4 + 2535dbf commit 14976c2

File tree

5 files changed

+50
-23
lines changed

5 files changed

+50
-23
lines changed

README.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import io.endee.client.types.SpaceType;
7777

7878
CreateIndexOptions options = CreateIndexOptions.builder("my_vectors", 384)
7979
.spaceType(SpaceType.COSINE)
80-
.precision(Precision.INT8D)
80+
.precision(Precision.INT8)
8181
.build();
8282

8383
client.createIndex(options);
@@ -92,7 +92,7 @@ client.createIndex(options);
9292
| `spaceType` | Distance metric - `COSINE`, `L2`, or `IP` (inner product) | `COSINE` |
9393
| `m` | Graph connectivity - higher values increase recall but use more memory | 16 |
9494
| `efCon` | Construction-time parameter - higher values improve index quality | 128 |
95-
| `precision` | Quantization precision | `INT8D` |
95+
| `precision` | Quantization precision | `INT8` |
9696

9797
### Create a Hybrid Index
9898

@@ -102,7 +102,7 @@ Hybrid indexes combine dense vector search with sparse vector search. Add the `s
102102
CreateIndexOptions options = CreateIndexOptions.builder("hybrid_index", 384)
103103
.sparseDimension(30000) // Sparse vector dimension (vocabulary size)
104104
.spaceType(SpaceType.COSINE)
105-
.precision(Precision.INT8D)
105+
.precision(Precision.INT8)
106106
.build();
107107

108108
client.createIndex(options);
@@ -189,12 +189,14 @@ for (QueryResult item : results) {
189189

190190
**Query Parameters:**
191191

192-
| Parameter | Description | Default | Max |
193-
| ---------------- | ------------------------------------------------------- | -------- | ---- |
194-
| `vector` | Query vector (must match index dimension) | Required | - |
195-
| `topK` | Number of results to return | 10 | 512 |
196-
| `ef` | Search quality parameter - higher values improve recall | 128 | 1024 |
197-
| `includeVectors` | Include vector data in results | false | - |
192+
| Parameter | Description | Default | Max |
193+
| -------------------------------- | ------------------------------------------------------- | ------- | --------- |
194+
| `vector` | Query vector (must match index dimension) | Required | - |
195+
| `topK` | Number of results to return | 10 | 512 |
196+
| `ef` | Search quality parameter - higher values improve recall | 128 | 1024 |
197+
| `includeVectors` | Include vector data in results | false | - |
198+
| `prefilterCardinalityThreshold` | Switch to postfiltering when estimated matches exceed this value | 10,000 | 1,000,000 |
199+
| `filterBoostPercentage` | Bias results toward filter matches (0 = disabled) | 0 | 100 |
198200

199201
## Filtered Querying
200202

@@ -223,6 +225,29 @@ List<QueryResult> results = index.query(
223225

224226
> **Note:** The `$range` operator supports values within **[0 - 999]**. Normalize larger values before upserting.
225227
228+
### Filter Params
229+
230+
Use `prefilterCardinalityThreshold` and `filterBoostPercentage` to fine-tune how filtering interacts with the ANN search:
231+
232+
```java
233+
List<QueryResult> results = index.query(
234+
QueryOptions.builder()
235+
.vector(new double[] {0.15, 0.25 /* ... */})
236+
.topK(5)
237+
.filter(List.of(
238+
Map.of("category", Map.of("$eq", "tech"))
239+
))
240+
.prefilterCardinalityThreshold(50_000) // Use postfilter when >50k vectors match
241+
.filterBoostPercentage(20) // Bias 20% toward filter-matching vectors
242+
.build()
243+
);
244+
```
245+
246+
| Parameter | Description | Default | Range |
247+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------- | ----------------- |
248+
| `prefilterCardinalityThreshold` | When the estimated number of vectors matching the filter exceeds this value, postfiltering is used instead of prefiltering. | 10,000 | 1,000–1,000,000 |
249+
| `filterBoostPercentage` | Percentage by which filter-matching vectors are boosted during scoring. Set to `0` to disable. Higher values favor filtered results. | 0 | 0–100 |
250+
226251
## Hybrid Search
227252

228253
### Upserting Hybrid Vectors
@@ -340,7 +365,7 @@ IndexDescription info = index.describe();
340365
System.out.println(info);
341366
// IndexDescription{name='my_index', spaceType=COSINE, dimension=384,
342367
// sparseDimension=0, isHybrid=false, count=1000,
343-
// precision=INT8D, m=16}
368+
// precision=INT8, m=16}
344369
```
345370

346371
### Check if Index is Hybrid
@@ -357,8 +382,8 @@ Endee supports different quantization precision levels:
357382
import io.endee.client.types.Precision;
358383

359384
Precision.BINARY // Binary quantization (1-bit) - smallest storage, fastest search
360-
Precision.INT8D // 8-bit integer quantization (default) - balanced performance
361-
Precision.INT16D // 16-bit integer quantization - higher precision
385+
Precision.INT8 // 8-bit integer quantization (default) - balanced performance
386+
Precision.INT16 // 16-bit integer quantization - higher precision
362387
Precision.FLOAT16 // 16-bit floating point - good balance
363388
Precision.FLOAT32 // 32-bit floating point - highest precision
364389
```
@@ -368,8 +393,8 @@ Precision.FLOAT32 // 32-bit floating point - highest precision
368393
| Precision | Use Case |
369394
| --------- | ------------------------------------------------------------------------- |
370395
| `BINARY` | Very large datasets where speed and storage are critical |
371-
| `INT8D` | Recommended for most use cases - good balance of accuracy and performance |
372-
| `INT16D` | Better accuracy than INT8D but less storage than FLOAT32 |
396+
| `INT8` | Recommended for most use cases - good balance of accuracy and performance |
397+
| `INT16` | Better accuracy than INT8 but less storage than FLOAT32 |
373398
| `FLOAT16` | Good compromise between precision and storage for embeddings |
374399
| `FLOAT32` | Maximum precision when storage is not a concern |
375400

@@ -435,7 +460,7 @@ public class EndeeExample {
435460
// Create a dense index
436461
CreateIndexOptions createOptions = CreateIndexOptions.builder("documents", 384)
437462
.spaceType(SpaceType.COSINE)
438-
.precision(Precision.INT8D)
463+
.precision(Precision.INT8)
439464
.build();
440465

441466
client.createIndex(createOptions);
@@ -515,7 +540,7 @@ CreateIndexOptions.builder(String name, int dimension)
515540
.spaceType(SpaceType) // Default: COSINE
516541
.m(int) // Default: 16
517542
.efCon(int) // Default: 128
518-
.precision(Precision) // Default: INT8D
543+
.precision(Precision) // Default: INT8
519544
.sparseDimension(Integer) // Optional, for hybrid indexes
520545
.build()
521546
```
@@ -525,12 +550,14 @@ CreateIndexOptions.builder(String name, int dimension)
525550
```java
526551
QueryOptions.builder()
527552
.vector(double[]) // Required for dense search
528-
.topK(int) // Required
529-
.ef(int) // Default: 128
553+
.topK(int) // Default: 10, max 512
554+
.ef(int) // Default: 128, max 1024
530555
.filter(List<Map<String, Object>>) // Optional
531556
.includeVectors(boolean) // Default: false
532557
.sparseIndices(int[]) // Optional, for hybrid search
533558
.sparseValues(double[]) // Optional, for hybrid search
559+
.prefilterCardinalityThreshold(int) // Default: 10000, range 1000–1000000
560+
.filterBoostPercentage(int) // Default: 0, range 0–100
534561
.build()
535562
```
536563

src/main/java/io/endee/client/Endee.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* // Create an index
3535
* CreateIndexOptions options = CreateIndexOptions.builder("my_index", 128)
3636
* .spaceType(SpaceType.COSINE)
37-
* .precision(Precision.INT8D)
37+
* .precision(Precision.INT8)
3838
* .build();
3939
* client.createIndex(options);
4040
*

src/main/java/io/endee/client/Index.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Index(String name, String token, String url, int version, IndexInfo param
7171
this.count = params != null ? params.getTotalElements() : 0;
7272
this.spaceType = params != null && params.getSpaceType() != null ? params.getSpaceType() : SpaceType.COSINE;
7373
this.dimension = params != null ? params.getDimension() : 0;
74-
this.precision = params != null && params.getPrecision() != null ? params.getPrecision() : Precision.INT8D;
74+
this.precision = params != null && params.getPrecision() != null ? params.getPrecision() : Precision.INT8;
7575
this.m = params != null ? params.getM() : 16;
7676
this.sparseDimension = params != null && params.getSparseDimension() != null ? params.getSparseDimension() : 0;
7777

src/main/java/io/endee/client/types/CreateIndexOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CreateIndexOptions {
99
private SpaceType spaceType = SpaceType.COSINE;
1010
private int m = 16;
1111
private int efCon = 128;
12-
private Precision precision = Precision.INT8D;
12+
private Precision precision = Precision.INT8;
1313
private Integer version = null;
1414
private Integer sparseDimension = null;
1515

src/main/java/io/endee/client/types/Precision.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
public enum Precision {
77
BINARY("binary"),
8-
INT8D("int8d"),
9-
INT16D("int16d"),
8+
INT8("int8"),
9+
INT16("int16"),
1010
FLOAT32("float32"),
1111
FLOAT16("float16");
1212

0 commit comments

Comments
 (0)