1919 * }</pre>
2020 */
2121public class QueryOptions {
22+ private static final int DEFAULT_PREFILTER_CARDINALITY_THRESHOLD = 10_000 ;
23+
2224 private double [] vector ;
2325 private int topK ;
2426 private List <Map <String , Object >> filter ;
2527 private int ef = 128 ;
2628 private boolean includeVectors = false ;
2729 private int [] sparseIndices ;
2830 private double [] sparseValues ;
31+ private int prefilterCardinalityThreshold = DEFAULT_PREFILTER_CARDINALITY_THRESHOLD ;
32+ private int filterBoostPercentage = 0 ;
2933
3034 private QueryOptions () {}
3135
@@ -40,6 +44,8 @@ public static Builder builder() {
4044 public boolean isIncludeVectors () { return includeVectors ; }
4145 public int [] getSparseIndices () { return sparseIndices ; }
4246 public double [] getSparseValues () { return sparseValues ; }
47+ public int getPrefilterCardinalityThreshold () { return prefilterCardinalityThreshold ; }
48+ public int getFilterBoostPercentage () { return filterBoostPercentage ; }
4349
4450 public static class Builder {
4551 private final QueryOptions options = new QueryOptions ();
@@ -86,6 +92,25 @@ public Builder sparseValues(double[] sparseValues) {
8692 return this ;
8793 }
8894
95+ /**
96+ * Sets the prefilter cardinality threshold. When the estimated number of
97+ * matching vectors exceeds this value, postfiltering is used instead.
98+ * Must be between 1,000 and 1,000,000. Default: 10,000.
99+ */
100+ public Builder prefilterCardinalityThreshold (int prefilterCardinalityThreshold ) {
101+ options .prefilterCardinalityThreshold = prefilterCardinalityThreshold ;
102+ return this ;
103+ }
104+
105+ /**
106+ * Sets the filter boost percentage (0-100). Higher values bias results
107+ * toward filter matches. Default: 0.
108+ */
109+ public Builder filterBoostPercentage (int filterBoostPercentage ) {
110+ options .filterBoostPercentage = filterBoostPercentage ;
111+ return this ;
112+ }
113+
89114 public QueryOptions build () {
90115 return options ;
91116 }
0 commit comments