adding Doc type for results

This commit is contained in:
Mark Wolters 2024-02-08 17:21:22 -04:00
parent b7b790766e
commit b16b04f466
2 changed files with 19 additions and 1 deletions

View File

@ -52,7 +52,7 @@ public class KnnSearchOpDispenser extends BaseOpenSearchOpDispenser {
.index(targetF.apply(1))
.query(new Query.Builder().knn(finalKnnfunc.apply(l).build()).build());
return (long l) -> new KnnSearchOp(clientF.apply(l), bfunc.apply(l).build(), Object.class);
return (long l) -> new KnnSearchOp(clientF.apply(l), bfunc.apply(l).build(), Doc.class);
}
private KnnQuery.Builder convertVector(KnnQuery.Builder builder, List list) {
@ -63,5 +63,22 @@ public class KnnSearchOpDispenser extends BaseOpenSearchOpDispenser {
return builder.vector(vector);
}
public static class Doc {
private float[] values;
public Doc() {}
public Doc(float[] values) {
this.values = values;
}
public float[] getValues() {
return values;
}
public void setValues(float[] values) {
this.values = values;
}
@Override
public String toString() {
return "{" + "values=" + values + "}";
}
}
}

View File

@ -21,3 +21,4 @@ blocks:
knn_search: TEMPLATE(indexname,vectors_index)
k: 100
vector: [1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f,13f,14f,15f,16f,17f,18f,19f,20f,21f,22f,23f,24f,25f]
field: value