-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add knn query support #539
Comments
Is this not closed by #524 ? |
As mentioned in my original description, opensearch-project/k-NN#524 adds the ability to construct an index with a Here are 2 example of a query which is currently unable to be constructed via opensearch-java:
|
Those queries should now be representable: client.search(s -> s
.index("foobar")
.size(3)
.query(q -> q
.knn(k -> k
.field("location")
.vector(new float[] { 5f, 4f })
.k(20)
)
),
Doc.class
);
client.search(s -> s
.index("foobar")
.size(3)
.query(q -> q
.knn(k -> k
.field("location")
.vector(new float[] { 5f, 4f })
.k(3)
.filter(Query.of(f -> f
.bool(b -> b
.must(m -> m
.range(r -> r
.field("rating")
.gte(JsonData.of(8))
.lte(JsonData.of(10))
)
)
.must(m -> m
.term(t -> t
.field("parking")
.value(FieldValue.TRUE)
)
)
)
))
)
),
Doc.class
); |
I had a quick read through and it appears to cover everything in this feature request. I'm happy for this feature request to be closed as fixed |
Is your feature request related to a problem?
Currently it is not possible to construct a query using opensearch-java with a knn query within it using the
Query
type:https://opensearch.org/docs/latest/search-plugins/knn/filter-search-knn/#boolean-filter-with-ann-search
https://opensearch.org/docs/latest/search-plugins/knn/filter-search-knn/#lucene-k-nn-filter-implementation
opensearch-java does not contain KnnQuery as a variant it supports and due to the Query.Kind being a enum and the QueryVariant interface requiring a kind being specified it cannot be implemented as a separate library.
What solution would you like?
Given that opensearch-project/k-NN#524 adds precedent for adding KNN functionality into opensearch-java directly and has support for script scoring KNN integration, it seems reasonable that KNN query support be added directly into opensearch-java by adding a
KNN
variant to theQuery.Kind
enum and addingKnnQuery
andKnnQuery.Builder
classes to allow for the construction of these queries.What alternatives have you considered?
Query.Kind
being an enum is restrictive in itself, preventing composability of client library support for non-bundled plugins. It could be that removing this restriction allows for the client to be built separately. But given opensearch-project/k-NN#524 was merged it seems like given if this restriction was removed, it still may be advantageous for consistency to add the KNN query supportDo you have any additional context?
Its not clear whether this request is the exact same thing as #547
The text was updated successfully, but these errors were encountered: