Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Java 17, Gradle 8.4, OpenSearch 2.15, OpenSearch kNN 2.15
Describe the issue:
Hi everyone, I want to use kNN plugin of OpenSearch in its Java client, however I am not able to use it. I added it as a dependency, it seems that I cannot even import it.
Configuration:
When I import a module in knn, like
import org.opensearch.knn.index.SpaceType;
the error is Cannot resolve symbol 'knn'.
Relevant Logs or Screenshots:
The library is shown in External Libraries but not able to import.
For those experiencing the same issue, if you use Gradle, it downloads the library as a .zip file. While I am not entirely sure if this resolves the problem, adding unzipping modules seems to help:
configurations {
knnZip
}
dependencies {
knnZip 'org.opensearch.plugin:opensearch-knn:2.15.0.0@zip'
}
task unzipKnn(type: Copy) {
from zipTree(configurations.knnZip.singleFile)
into "$buildDir/libs/opensearch-knn"
}
tasks.named('build') {
dependsOn 'unzipKnn'
}
sourceSets {
main {
runtimeClasspath += fileTree(dir: "$buildDir/libs/opensearch-knn", include: '**/*.jar')
}
}
then clean build as ./gradlew clean build.
So after a few trials, my solution does not seem to work for me
I downloaded .jar file from maven and add it to my projects libs/path and then configured my gradle file as this
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
then clean build.