buildKnnRankMap(Knn knn) {
return wrapper;
}
+ /**
+ * Expands RRF into arithmetic rank expressions that the server understands.
+ * The server has no native {@code $rrf} operator — RRF is a client-side formula:
+ * {@code -(sum(weight_i / (k + rank_i)))}
+ *
+ * When {@code normalize} is enabled, each weight is first divided by the sum of all
+ * weights before expansion (i.e., {@code w_i' = w_i / sum(w)}).
+ *
+ * Each term becomes: {@code $div { left: $val(weight), right: $sum[$val(k), $knn(...)] }}
+ * All terms are summed (single term: {@code $div} directly, no {@code $sum} wrapper),
+ * then negated (RRF: higher is better → Chroma: lower is better).
+ */
static Map buildRrfRankMap(Rrf rrf) {
- Map rrfMap = new LinkedHashMap();
- List