Problem importing org.opensearch.knn in Java

I’ve added K-NN plugin as dependency in my build.gradle:

implementation("org.opensearch.plugin:opensearch-knn:2.3.0.0")

But I still get unresolved reference error when trying to import anything from org.opensearch.knn.

How can I fix this and use the K-NN plugin for making queries from Java? I’m trying to import KNNQueryBuilder.

Hi @Alireza
Is this for a plugin you are building? Or making a call to k-nn?

Just making calls to k-nn

In that case you don’t have to take dependency in K-NN plugin. The kNNQuerybuilder class is an internal class used for building the k-nn internal queries.

I would recommend checking the java client if Opensearch to see if it supports creating k-nn query. If thats not the case please create raw json query as per k-nn documentation.

Also, feel free to cut a github issue on opensearch java client if it doesn’t support building k-nn queries.

@Alireza

1 Like

Thanks for the response.
I think this is the Java client repo and the one you mentioned is for building and running extensions.
And there seems to be a issue with knn already :sob:

@Alireza thanks for fixing the link.

The issue which you have mentioned on top is for indexing of the knn vectors. I checked little bit more and I am not able to find for the classes for query of knn.
Ref: opensearch-java/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl at main · opensearch-project/opensearch-java · GitHub

Found some reference issues: [FEATURE] Add knn builder and query search support · Issue #634 · opensearch-project/k-NN · GitHub see if it can help.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.