From f0faaba385e7fb754cbeb73fed33257c3ecca65d Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Tue, 12 Dec 2023 22:07:16 +1000 Subject: [PATCH 1/2] Contribute qdrant java client This commit contributes a java client for qdrant. - Gradle is used for build automation. Easy to extend with additional tasks, and fast for incremental builds. - A Custom gradle task downloads protos from qdrant/qdrant, based on version specified in properties, which can be passed by commandline. No need to check in versioned protos, and protos are auto patched to include java package name. - Project is configured with No nulls by default, NullAway, Errorprone, enforcement of JavaDocs. - Ability to pass a channel to the client. This allows users to configure channel credentials however they need to for their environment e.g. self-signed certs for TLS, proxies, etc. - Ability for the client to manage the lifetime of the channel. A singleton instance of the client would typically be created, and Spring Boot is a popular choice for DI. Being able to configure the client to shutdown the channel on close is useful, as Spring can take care of it. - Exposes async methods that return ListenableFuture which can be composed to form concurrent operations, or called and waited on with .get(), optionally with a timeout. - Exposes ability to set an overall default timeout for all calls, and optionally provide a timeout per call. - Client is configured with logging, all calls are debug logged, and all exceptions are error logged. - Overloaded methods for common operations. Some operations have many parameters that are optional, so the builder types are used. --- .editorconfig | 18 + .gitattributes | 11 + .github/workflows/build.yml | 65 + .github/workflows/cd.yml | 42 - .github/workflows/test.yml | 29 - .gitignore | 62 +- .idea/.gitignore | 8 + .idea/.name | 1 + .idea/gradle.xml | 29 + .idea/misc.xml | 58 + .idea/vcs.xml | 6 + CONTRIBUTING.md | 124 + build.gradle | 231 + buildSrc/build.gradle | 9 + gradle.properties | 8 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 63375 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 248 ++ gradlew.bat | 92 + pom.xml | 136 - settings.gradle | 2 + .../io/qdrant/client/ApiKeyCredentials.java | 35 + .../io/qdrant/client/ConditionFactory.java | 373 ++ .../java/io/qdrant/client/PointIdFactory.java | 31 + .../java/io/qdrant/client/QdrantClient.java | 3790 +++++++++++------ .../io/qdrant/client/QdrantException.java | 14 + .../io/qdrant/client/QdrantGrpcClient.java | 219 + .../io/qdrant/client/TokenInterceptor.java | 37 - .../java/io/qdrant/client/ValueFactory.java | 70 + .../java/io/qdrant/client/VectorsFactory.java | 60 + .../client/WithPayloadSelectorFactory.java | 46 + .../client/WithVectorsSelectorFactory.java | 35 + .../java/io/qdrant/client/package-info.java | 7 + .../io/qdrant/client/utils/FilterUtil.java | 375 -- .../io/qdrant/client/utils/PayloadUtil.java | 154 - .../io/qdrant/client/utils/PointUtil.java | 233 - .../io/qdrant/client/utils/SelectorUtil.java | 92 - .../io/qdrant/client/utils/VectorUtil.java | 131 - src/main/proto/collections.proto | 448 -- src/main/proto/collections_service.proto | 50 - src/main/proto/json_with_int.proto | 63 - src/main/proto/points.proto | 646 --- src/main/proto/points_service.proto | 93 - src/main/proto/qdrant.proto | 20 - src/main/proto/snapshots_service.proto | 77 - .../java/io/qdrant/client/ApiKeyTest.java | 66 + .../io/qdrant/client/CollectionsTest.java | 254 ++ .../java/io/qdrant/client/HealthTest.java | 48 + .../java/io/qdrant/client/PointsTest.java | 532 +++ .../client/QdrantClientCollectionTest.java | 158 - .../qdrant/client/QdrantClientPointsTest.java | 264 -- .../client/QdrantClientServiceTest.java | 44 - .../client/QdrantClientSnapshotsTest.java | 106 - .../qdrant/client/QdrantGrpcClientTest.java | 47 + .../java/io/qdrant/client/SnapshotsTest.java | 150 + .../client/container/QdrantContainer.java | 41 + .../java/io/qdrant/client/package-info.java | 4 + .../qdrant/client/utils/FilterUtilTest.java | 312 -- .../qdrant/client/utils/PayloadUtilTest.java | 165 - .../io/qdrant/client/utils/PointUtilTest.java | 186 - .../qdrant/client/utils/SelectorUtilTest.java | 66 - .../qdrant/client/utils/VectorUtilTest.java | 79 - tools/mvn_test.sh | 33 - 63 files changed, 5402 insertions(+), 5438 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/cd.yml delete mode 100644 .github/workflows/test.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 CONTRIBUTING.md create mode 100644 build.gradle create mode 100644 buildSrc/build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat delete mode 100644 pom.xml create mode 100644 settings.gradle create mode 100644 src/main/java/io/qdrant/client/ApiKeyCredentials.java create mode 100644 src/main/java/io/qdrant/client/ConditionFactory.java create mode 100644 src/main/java/io/qdrant/client/PointIdFactory.java create mode 100644 src/main/java/io/qdrant/client/QdrantException.java create mode 100644 src/main/java/io/qdrant/client/QdrantGrpcClient.java delete mode 100644 src/main/java/io/qdrant/client/TokenInterceptor.java create mode 100644 src/main/java/io/qdrant/client/ValueFactory.java create mode 100644 src/main/java/io/qdrant/client/VectorsFactory.java create mode 100644 src/main/java/io/qdrant/client/WithPayloadSelectorFactory.java create mode 100644 src/main/java/io/qdrant/client/WithVectorsSelectorFactory.java create mode 100644 src/main/java/io/qdrant/client/package-info.java delete mode 100644 src/main/java/io/qdrant/client/utils/FilterUtil.java delete mode 100644 src/main/java/io/qdrant/client/utils/PayloadUtil.java delete mode 100644 src/main/java/io/qdrant/client/utils/PointUtil.java delete mode 100644 src/main/java/io/qdrant/client/utils/SelectorUtil.java delete mode 100644 src/main/java/io/qdrant/client/utils/VectorUtil.java delete mode 100644 src/main/proto/collections.proto delete mode 100644 src/main/proto/collections_service.proto delete mode 100644 src/main/proto/json_with_int.proto delete mode 100644 src/main/proto/points.proto delete mode 100644 src/main/proto/points_service.proto delete mode 100644 src/main/proto/qdrant.proto delete mode 100644 src/main/proto/snapshots_service.proto create mode 100644 src/test/java/io/qdrant/client/ApiKeyTest.java create mode 100644 src/test/java/io/qdrant/client/CollectionsTest.java create mode 100644 src/test/java/io/qdrant/client/HealthTest.java create mode 100644 src/test/java/io/qdrant/client/PointsTest.java delete mode 100644 src/test/java/io/qdrant/client/QdrantClientCollectionTest.java delete mode 100644 src/test/java/io/qdrant/client/QdrantClientPointsTest.java delete mode 100644 src/test/java/io/qdrant/client/QdrantClientServiceTest.java delete mode 100644 src/test/java/io/qdrant/client/QdrantClientSnapshotsTest.java create mode 100644 src/test/java/io/qdrant/client/QdrantGrpcClientTest.java create mode 100644 src/test/java/io/qdrant/client/SnapshotsTest.java create mode 100644 src/test/java/io/qdrant/client/container/QdrantContainer.java create mode 100644 src/test/java/io/qdrant/client/package-info.java delete mode 100644 src/test/java/io/qdrant/client/utils/FilterUtilTest.java delete mode 100644 src/test/java/io/qdrant/client/utils/PayloadUtilTest.java delete mode 100644 src/test/java/io/qdrant/client/utils/PointUtilTest.java delete mode 100644 src/test/java/io/qdrant/client/utils/SelectorUtilTest.java delete mode 100644 src/test/java/io/qdrant/client/utils/VectorUtilTest.java delete mode 100644 tools/mvn_test.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d19e182d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 4 + +[*.{md,markdown,json,js,xml,yml}] +indent_style = space +indent_size = 2 + +[*.{md,markdown}] +trim_trailing_whitespace = false +max_line_length = 80 + +[*.{sh,bat,ps1}] +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..3776e59c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# Auto detect text files and perform LF normalization +* text=auto eol=lf + +# Set default behavior for command prompt diff. +# This gives output on command line taking java language constructs into consideration (e.g showing class name) +*.java text diff=java + +# Set windows specific files explicitly to crlf line ending +*.cmd eol=crlf +*.bat eol=crlf +*.ps1 eol=crlf \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..9aafe3a8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build + +on: + push: + branches: [ "master" ] + pull_request_target: + branches: [ "master" ] + +permissions: + contents: read + checks: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 8.5 + arguments: build + + - name: Test + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 8.5 + arguments: test + + - name: Test Results + uses: mikepenz/action-junit-report@v4 + if: always() + with: + fail_on_failure: true + require_tests: true + report_paths: '**/build/test-results/test/TEST-*.xml' + + - name: Upload Jars + uses: actions/upload-artifact@v3 + with: + name: QdrantJava + path: build/libs + + publish: + runs-on: ubuntu-latest + needs: test + steps: + - name: Deploy javadoc to Github Pages + uses: dev-vince/actions-publish-javadoc@v1.0.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + java-version: "8" + java-distribution: "adopt" # The distributor of the target JDK. See https://github.com/actions/setup-java for more information. + project: maven # The project type. + branch: "gh-pages" # The branch for the javadoc contents. diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 4b345eba..00000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Test And Deploy - -permissions: - contents: write - -on: - push: - branches: - - master - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - java-version: ["8", "11", "16", "17", "21"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java-version }} - distribution: "temurin" - - name: Set execute permission - run: | - chmod +x ./tools/mvn_test.sh - - name: Maven tests - run: | - ./tools/mvn_test.sh - shell: bash - - publish: - runs-on: ubuntu-latest - needs: test - steps: - - name: Deploy javadoc to Github Pages - uses: dev-vince/actions-publish-javadoc@v1.0.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - java-version: "8" - java-distribution: "adopt" # The distributor of the target JDK. See https://github.com/actions/setup-java for more information. - project: maven # The project type. - branch: "gh-pages" # The branch for the javadoc contents. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index cd540363..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Maven Tests - -on: - pull_request: - types: - - opened - - edited - - synchronize - - reopened - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - java-version: ["8", "11", "16", "17", "21"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java-version }} - distribution: "temurin" - - name: Set execute permission - run: | - chmod +x ./tools/mvn_test.sh - - name: Maven tests - run: | - ./tools/mvn_test.sh - shell: bash diff --git a/.gitignore b/.gitignore index 94c668b5..b5136074 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,47 @@ -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -# https://github.com/takari/maven-wrapper#usage-without-binary-jar -.mvn/wrapper/maven-wrapper.jar +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ -# Eclipse m2e generated files -# Eclipse Core -.project -# JDT-specific (Eclipse Java Development Tools) +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +.idea/uiDesigner.xml +.idea/codeStyles/codeStyleConfig.xml +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated .classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ -# VS Code -.vscode/* +### Mac OS ### +.DS_Store -# Others -.DS_Store \ No newline at end of file +### Project specific ### +protos diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000..2a11f8b9 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +client \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 00000000..e7c302f9 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..11303e26 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..05b20cb8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,124 @@ +# Contributing to Java client for Qdrant + +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features + +## We Develop with GitHub + +We use github to host code, to track issues and feature requests, as well as accept pull requests. + +We Use [GitHub Flow](https://docs.github.com/en/get-started/quickstart/github-flow), so all code changes +happen through Pull Requests. Pull requests are the best way to propose changes to the codebase. + +It's usually best to open an issue first to discuss a feature or bug before opening a pull request. +Doing so can save time and help further ascertain the crux of an issue. + +1. See if there is an existing issue +2. Fork the repo and create your branch from `master`. +3. If you've added code that should be tested, add tests. +4. Ensure the test suite passes. +5. Issue that pull request! + +### Any contributions you make will be under the Apache License 2.0 + +In short, when you submit code changes, your submissions are understood to be under the +same [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/) that covers the project. +Feel free to contact the maintainers if that's a concern. + +## Report bugs using GitHub's [issues](https://github.com/qdrant/java-client/issues) + +We use GitHub issues to track public bugs. Report a bug by +[opening a new issue](https://github.com/qdrant/java-client/issues/new); it's that easy! + +**Great Bug Reports** tend to have: + +- A quick summary and/or background +- Steps to reproduce + - Be specific! + - Give sample code if you can. +- What you expected would happen +- What actually happens +- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) + +## Coding Styleguide + +If you are modifying code, make sure it has no warnings when building. + +## License + +By contributing, you agree that your contributions will be licensed under its Apache License 2.0. + +# Building the solution + +The solution uses several open source software tools: + +## Docker + +Qdrant docker image is used to run integration tests. Be sure to +[install docker](https://docs.docker.com/engine/install/) and have it running when running tests. + +## Gradle + +[Gradle](https://docs.gradle.org/current/userguide/userguide.html) is used as the build automation tool for the solution. +To get started after cloning the solution, it's best to run the gradlew wrapper script in the root + +for Windows + +``` +.\gradlew.bat build +``` + +for OSX/Linux + +``` +./gradlew build +``` + +This will + +- Pull down all the dependencies for the build process as well as the solution +- Run the default build task for the solution + +You can also compile the solution within IntelliJ or other IDEs if you prefer. + +## Tests + +jUnit5 tests are run as part of the default build task. These can also be run with + +``` +./gradlew test +``` + +## Updating the client + +A large portion of the client is generated from the upstream qdrant proto definitions, which are +downloaded locally as needed, based on the version defined by `qdrantProtosVersion` in gradle.properties +in the root directory. + +When a new qdrant version is released upstream, update the `qdrantProtosVersion` value to the new version, +then run the build script + +for Windows + +``` +.\gradlew.bat build +``` + +for OSX/Linux + +``` +./gradlew build +``` + +A specific version of the qdrant docker image can be targeted by modifying the `qdrantVersion` +in gradle.properties. + +The generated files do not form part of the checked in source code. Instead, they are generated +and emitted into the build/generated/source directory, and included in compilation. + +If upstream changes to proto definitions change the API of generated code, you may need +to fix compilation errors in code that relies on that generated code. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..722d6c0e --- /dev/null +++ b/build.gradle @@ -0,0 +1,231 @@ +import net.ltgt.gradle.errorprone.CheckSeverity +import org.ajoberstar.grgit.Grgit +import org.apache.commons.compress.archivers.tar.TarArchiveEntry +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream +import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream +import org.apache.http.client.methods.HttpGet +import org.apache.http.impl.client.HttpClients + +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardOpenOption +import java.time.ZoneOffset +import java.util.regex.Pattern + +plugins { + id 'java-library' + id 'idea' + id 'signing' + id 'maven-publish' + + id 'com.google.protobuf' version '0.9.4' + id "net.ltgt.errorprone" version '3.1.0' +} + +group = 'io.qdrant' +version = packageVersion +description = 'Official Java client for Qdrant vector database' + +repositories { + // google mirror for maven + maven { + url 'https://maven-central.storage-download.googleapis.com/maven2/' + } + mavenCentral() + mavenLocal() +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + withJavadocJar() + withSourcesJar() +} + +tasks.withType(JavaCompile).configureEach { + // exclude generated code from error prone checks + options.errorprone.excludedPaths.set(".*/build/generated/.*") + options.errorprone { + //noinspection GroovyAssignabilityCheck + check("NullAway", CheckSeverity.ERROR) + option("NullAway:AnnotatedPackages", "com.uber") + } +} + +javadoc { + // exclude code generated from protos + exclude 'io/qdrant/client/grpc/**' + exclude 'grpc/**' +} + +sourcesJar { + // exclude generated duplicate of com/qdrant/client/grpc/CollectionsGrpc.java + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +jar { + doFirst { + def git = Grgit.open(Map.of('currentDir', rootProject.rootDir)) + // add qdrant version from which client is generated. + jar.manifest.attributes['X-Qdrant-Version'] = qdrantProtosVersion + // add git revision and commit time to jar manifest + jar.manifest.attributes['X-Git-Revision'] = git.head().id + jar.manifest.attributes['X-Git-Commit-Time'] = git.head().dateTime.withZoneSameLocal(ZoneOffset.UTC) + git.close() + } +} + +def grpcVersion = '1.59.0' +def protobufVersion = '3.24.0' +def protocVersion = protobufVersion +def testContainersVersion = '1.19.2' +def jUnitVersion = '5.8.1' + +dependencies { + errorprone "com.uber.nullaway:nullaway:0.10.18" + + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-services:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "com.google.guava:guava:30.1-jre" + implementation "org.slf4j:slf4j-api:2.0.7" + + compileOnly "org.apache.tomcat:annotations-api:6.0.53" + compileOnly "com.google.code.findbugs:jsr305:3.0.2" + + errorprone "com.google.errorprone:error_prone_core:2.23.0" + + runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" + + testImplementation "io.grpc:grpc-testing:${grpcVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${jUnitVersion}" + testImplementation "org.mockito:mockito-core:3.4.0" + testImplementation "org.testcontainers:testcontainers:${testContainersVersion}" + testImplementation "org.testcontainers:junit-jupiter:${testContainersVersion}" + + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jUnitVersion}" +} + +tasks.register('downloadProtos') { + // gradle detects changes to this output dir since last run to determine whether to run this task + outputs.dir(new File(rootProject.rootDir, "protos/${qdrantProtosVersion}")) + + doLast { + def outputDirectory = outputs.files.singleFile.toPath().toString() + def protoFileRegex = Pattern.compile(".*?lib/api/src/grpc/proto/.*?.proto") + try (def httpClient = HttpClients.createDefault()) { + def url = "https://api.github.com/repos/qdrant/qdrant/tarball/refs/tags/${qdrantProtosVersion}" + logger.debug("downloading protos from {}", url) + def response = httpClient.execute(new HttpGet(url)) + try (InputStream tarballStream = response.getEntity().getContent()) { + try (TarArchiveInputStream tarInput = new TarArchiveInputStream(new GzipCompressorInputStream(tarballStream))) { + TarArchiveEntry entry + while ((entry = tarInput.getNextTarEntry()) != null) { + if (!entry.isDirectory() && protoFileRegex.matcher(entry.getName()).matches()) { + def lines = new ArrayList() + def lineNum = -1 + def seenJavaPackage = false + def br = new BufferedReader(new InputStreamReader(tarInput)) + String line + while ((line = br.readLine()) != null) { + lines.add(line) + if (line == "package qdrant;") { + lineNum = lines.size() + } else if (line.startsWith("option java_package")) { + seenJavaPackage = true + } + } + // patch in java package to qdrant protos + if (!seenJavaPackage && lineNum != -1) { + lines.add(lineNum, "option java_package = \"io.qdrant.client.grpc\";") + } + + def fileName = Paths.get(entry.getName()).getFileName().toString() + def dest = java.nio.file.Path.of(outputDirectory, fileName) + logger.debug("writing {} to {}", fileName, dest) + Files.write(dest, lines, StandardOpenOption.CREATE) + } + } + } + } + } + } +} + +processResources { + dependsOn downloadProtos +} + +extractIncludeProto { + dependsOn downloadProtos +} + +protobuf { + protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } + plugins { + grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } + } + generateProtoTasks { + all()*.plugins { grpc {} } + } +} + +// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code. +sourceSets { + main { + proto { + // include protos from outside the sourceSets + //noinspection GroovyAssignabilityCheck + srcDir "protos/${qdrantProtosVersion}" + } + java { + srcDirs 'build/generated/source/proto/main/grpc' + srcDirs 'build/generated/source/proto/main/java' + } + } +} + +test { + useJUnitPlatform() + + // Set system property to use as docker image version for integration tests + systemProperty 'qdrantVersion', qdrantVersion +} + +def organization = 'qdrant' +def repository = 'java-client' + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + pom { + description = "${project.description}" + url = "https://github.com/${organization}/${repository}" + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' + } + } + developers { + developer { + id = 'qdrant' + name = 'Qdrant and Contributors' + email = 'info@qdrant.com' + } + } + scm { + connection = "scm:git:git://github.com/${organization}/${repository}.git" + developerConnection = "scm:git:ssh://github.com/${organization}/${repository}.git" + url = "https://github.com/${organization}/${repository}" + } + } + } + } + repositories { + mavenLocal() + } +} \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..d90e0954 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,9 @@ +dependencies { + implementation 'org.ajoberstar.grgit:grgit-gradle:5.0.0' + implementation 'org.apache.httpcomponents:httpclient:4.5.14' + implementation 'org.apache.commons:commons-compress:1.23.0' +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..44e0858b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +# The version of qdrant to use to download protos +qdrantProtosVersion=v1.7.0 + +# The version of qdrant docker image to run integration tests against +qdrantVersion=v1.7.0 + +# The version of the client to generate +packageVersion=1.7-SNAPSHOT \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..033e24c4cdf41af1ab109bc7f253b2b887023340 GIT binary patch literal 63375 zcmb5VV{~QRw)Y#`wrv{~+qP{x72B%VwzFc}c2cp;N~)5ZbDrJayPv(!dGEd-##*zr z)#n-$y^sH|_dchh3@8{H5D*j;5D<{i*8l5IFJ|DjL!e)upfGNX(kojugZ3I`oH1PvW`wFW_ske0j@lB9bX zO;2)`y+|!@X(fZ1<2n!Qx*)_^Ai@Cv-dF&(vnudG?0CsddG_&Wtae(n|K59ew)6St z#dj7_(Cfwzh$H$5M!$UDd8=4>IQsD3xV=lXUq($;(h*$0^yd+b{qq63f0r_de#!o_ zXDngc>zy`uor)4A^2M#U*DC~i+dc<)Tb1Tv&~Ev@oM)5iJ4Sn#8iRw16XXuV50BS7 zdBL5Mefch(&^{luE{*5qtCZk$oFr3RH=H!c3wGR=HJ(yKc_re_X9pD` zJ;uxPzUfVpgU>DSq?J;I@a+10l0ONXPcDkiYcihREt5~T5Gb}sT0+6Q;AWHl`S5dV>lv%-p9l#xNNy7ZCr%cyqHY%TZ8Q4 zbp&#ov1*$#grNG#1vgfFOLJCaNG@K|2!W&HSh@3@Y%T?3YI75bJp!VP*$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QJz1joB&M(Teg_>;yS<2-5>BWfSPpG`Rt{!j6>kqMAvl^zk0JUEfy$HVJMkxP-GkwZuxL62me2#pj_5*ZIU zP~#C^OZLfl$HO)v;~~c&JHivn|1I9H5y_CDkt0JLLGKm(4*KLVhJ2jh2#vJuM6`b& zE==-lvME^Oj022xF&IV*? '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..93e3f59f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index b728c7c6..00000000 --- a/pom.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - 4.0.0 - - io.qdrant - client - - 1.0 - - - - io.grpc - grpc-netty-shaded - 1.59.0 - runtime - - - io.grpc - grpc-protobuf - 1.59.0 - - - io.grpc - grpc-stub - 1.59.0 - - - org.apache.tomcat - annotations-api - 6.0.53 - provided - - - - org.junit.jupiter - junit-jupiter-engine - 5.5.2 - test - - - - - - - - kr.motd.maven - os-maven-plugin - 1.7.1 - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - - com.google.protobuf:protoc:3.24.0:exe:${os.detected.classifier} - grpc-java - - io.grpc:protoc-gen-grpc-java:1.59.0:exe:${os.detected.classifier} - - - - - compile - compile-custom - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - io.qdrant.client.Main - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M3 - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.6.2 - - - maven-compiler-plugin - 3.11.0 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - com.coveo - fmt-maven-plugin - 2.9 - - - - format - - - - - - - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..dd1a777f --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'client' + diff --git a/src/main/java/io/qdrant/client/ApiKeyCredentials.java b/src/main/java/io/qdrant/client/ApiKeyCredentials.java new file mode 100644 index 00000000..d3a02e4f --- /dev/null +++ b/src/main/java/io/qdrant/client/ApiKeyCredentials.java @@ -0,0 +1,35 @@ +package io.qdrant.client; + +import io.grpc.CallCredentials; +import io.grpc.Metadata; +import io.grpc.Status; + +import java.util.concurrent.Executor; + +/** + * API key authentication credentials + */ +public class ApiKeyCredentials extends CallCredentials { + private final String apiKey; + + /** + * Instantiates a new instance of {@link ApiKeyCredentials} + * @param apiKey The API key to use for authentication + */ + public ApiKeyCredentials(String apiKey) { + this.apiKey = apiKey; + } + + @Override + public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) { + appExecutor.execute(() -> { + try { + Metadata headers = new Metadata(); + headers.put(Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER), apiKey); + applier.apply(headers); + } catch (Throwable e) { + applier.fail(Status.UNAUTHENTICATED.withCause(e)); + } + }); + } +} diff --git a/src/main/java/io/qdrant/client/ConditionFactory.java b/src/main/java/io/qdrant/client/ConditionFactory.java new file mode 100644 index 00000000..5af72f55 --- /dev/null +++ b/src/main/java/io/qdrant/client/ConditionFactory.java @@ -0,0 +1,373 @@ +package io.qdrant.client; + +import java.util.List; + +import static io.qdrant.client.grpc.Points.Condition; +import static io.qdrant.client.grpc.Points.FieldCondition; +import static io.qdrant.client.grpc.Points.Filter; +import static io.qdrant.client.grpc.Points.GeoBoundingBox; +import static io.qdrant.client.grpc.Points.GeoLineString; +import static io.qdrant.client.grpc.Points.GeoPoint; +import static io.qdrant.client.grpc.Points.GeoPolygon; +import static io.qdrant.client.grpc.Points.GeoRadius; +import static io.qdrant.client.grpc.Points.HasIdCondition; +import static io.qdrant.client.grpc.Points.IsEmptyCondition; +import static io.qdrant.client.grpc.Points.IsNullCondition; +import static io.qdrant.client.grpc.Points.Match; +import static io.qdrant.client.grpc.Points.NestedCondition; +import static io.qdrant.client.grpc.Points.PointId; +import static io.qdrant.client.grpc.Points.Range; +import static io.qdrant.client.grpc.Points.RepeatedIntegers; +import static io.qdrant.client.grpc.Points.RepeatedStrings; +import static io.qdrant.client.grpc.Points.ValuesCount; + +/** + * Convenience methods for constructing {@link Condition} + */ +public final class ConditionFactory { + private ConditionFactory() { + } + + /** + * Match all records with the provided id + * @param id The id to match + * @return a new instance of {@link Condition} + */ + public static Condition hasId(PointId id) { + return Condition.newBuilder() + .setHasId(HasIdCondition.newBuilder() + .addHasId(id) + .build()) + .build(); + } + + /** + * Match all records with the provided ids + * @param ids The ids to match + * @return a new instance of {@link Condition} + */ + public static Condition hasId(List ids) { + return Condition.newBuilder() + .setHasId(HasIdCondition.newBuilder() + .addAllHasId(ids) + .build()) + .build(); + } + + /** + * Match all records where the given field either does not exist, or has null or empty value. + * @param field The name of the field + * @return a new instance of {@link Condition} + */ + public static Condition isEmpty(String field) { + return Condition.newBuilder() + .setIsEmpty(IsEmptyCondition.newBuilder() + .setKey(field) + .build()) + .build(); + } + + /** + * Match all records where the given field is null. + * @param field The name of the field + * @return a new instance of {@link Condition} + */ + public static Condition isNull(String field) { + return Condition.newBuilder() + .setIsNull(IsNullCondition.newBuilder() + .setKey(field) + .build()) + .build(); + } + + /** + * Match records where the given field matches the given keyword + * @param field The name of the field + * @param keyword The keyword to match + * @return a new instance of {@link Condition} + */ + public static Condition matchKeyword(String field, String keyword) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setKeyword(keyword) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field matches the given text. + * @param field The name of the field + * @param text The text to match + * @return a new instance of {@link Condition} + */ + public static Condition matchText(String field, String text) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setText(text) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field matches the given boolean value. + * @param field The name of the field + * @param value The value to match + * @return a new instance of {@link Condition} + */ + public static Condition match(String field, boolean value) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setBoolean(value) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field matches the given long value. + * @param field The name of the field + * @param value The value to match + * @return a new instance of {@link Condition} + */ + public static Condition match(String field, long value) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setInteger(value) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field matches any of the given keywords. + * @param field The name of the field + * @param keywords The keywords to match + * @return a new instance of {@link Condition} + */ + public static Condition matchKeywords(String field, List keywords) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setKeywords(RepeatedStrings.newBuilder().addAllStrings(keywords).build()) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field matches any of the given values. + * @param field The name of the field + * @param values The values to match + * @return a new instance of {@link Condition} + */ + public static Condition matchValues(String field, List values) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setIntegers(RepeatedIntegers.newBuilder().addAllIntegers(values).build()) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field does not match any of the given keywords. + * @param field The name of the field + * @param keywords The keywords not to match + * @return a new instance of {@link Condition} + */ + public static Condition matchExceptKeywords(String field, List keywords) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setExceptKeywords(RepeatedStrings.newBuilder().addAllStrings(keywords).build()) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field does not match any of the given values. + * @param field The name of the field + * @param values The values not to match + * @return a new instance of {@link Condition} + */ + public static Condition matchExceptValues(String field, List values) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setMatch(Match.newBuilder() + .setExceptIntegers(RepeatedIntegers.newBuilder().addAllIntegers(values).build()) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given nested field matches the given condition. + * @param field The name of the nested field. + * @param condition The condition to match. + * @return a new instance of {@link Condition} + */ + public static Condition nested(String field, Condition condition) { + return Condition.newBuilder() + .setNested(NestedCondition.newBuilder() + .setKey(field) + .setFilter(Filter.newBuilder() + .addMust(condition) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given nested field matches the given filter. + * @param field The name of the nested field. + * @param filter The filter to match. + * @return a new instance of {@link Condition} + */ + public static Condition nested(String field, Filter filter) { + return Condition.newBuilder() + .setNested(NestedCondition.newBuilder() + .setKey(field) + .setFilter(filter)) + .build(); + } + + /** + * Match records where the given field matches the given range. + * @param field The name of the nested field. + * @param range The range to match. + * @return a new instance of {@link Condition} + */ + public static Condition range(String field, Range range) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setRange(range) + .build()) + .build(); + } + + /** + * Match records where the given field has values inside a circle centred at a given latitude and longitude + * with a given radius. + * @param field The name of the field. + * @param latitude The latitude of the center. + * @param longitude The longitude of the center. + * @param radius The radius in meters. + * @return a new instance of {@link Condition} + */ + public static Condition geoRadius(String field, double latitude, double longitude, float radius) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setGeoRadius(GeoRadius.newBuilder() + .setCenter(GeoPoint.newBuilder() + .setLat(latitude) + .setLon(longitude) + .build()) + .setRadius(radius) + .build()) + .build()) + .build(); + } + + /** + * Match records where the given field has values inside a bounding box specified by the top left and + * bottom right coordinates. + * @param field The name of the field. + * @param topLeftLatitude The latitude of the top left point. + * @param topLeftLongitude The longitude of the top left point. + * @param bottomRightLatitude The latitude of the bottom right point. + * @param bottomRightLongitude The longitude of the bottom right point. + * @return a new instance of {@link Condition} + */ + public static Condition geoBoundingBox( + String field, + double topLeftLatitude, + double topLeftLongitude, + double bottomRightLatitude, + double bottomRightLongitude) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setGeoBoundingBox(GeoBoundingBox.newBuilder() + .setTopLeft(GeoPoint.newBuilder() + .setLat(topLeftLatitude) + .setLon(topLeftLongitude) + .build()) + .setBottomRight(GeoPoint.newBuilder() + .setLat(bottomRightLatitude) + .setLon(bottomRightLongitude) + .build()) + .build()) + .build()) + .build(); + } + + /** + * Matches records where the given field has values inside the provided polygon. A polygon always has an exterior + * ring and may optionally have interior rings, which represent independent areas or holes. + * When defining a ring, you must pick either a clockwise or counterclockwise ordering for your points. + * The first and last point of the polygon must be the same. + * @param field The name of the field. + * @param exterior The exterior ring of the polygon. + * @param interiors The interior rings of the polygon. + * @return a new instance of {@link Condition} + */ + public static Condition geoPolygon(String field, GeoLineString exterior, List interiors) { + GeoPolygon.Builder geoPolygonBuilder = GeoPolygon.newBuilder() + .setExterior(exterior); + + if (!interiors.isEmpty()) { + geoPolygonBuilder.addAllInteriors(interiors); + } + + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setGeoPolygon(geoPolygonBuilder.build()) + .build()) + .build(); + } + + /** + * Matches records where the given field has a count of values within the specified count range + * @param field The name of the field. + * @param valuesCount The count range to match. + * @return a new instance of {@link Condition} + */ + public static Condition valuesCount(String field, ValuesCount valuesCount) { + return Condition.newBuilder() + .setField(FieldCondition.newBuilder() + .setKey(field) + .setValuesCount(valuesCount) + .build()) + .build(); + } + + /** + * Nests a filter + * @param filter The filter to nest. + * @return a new instance of {@link Condition} + */ + public static Condition filter(Filter filter) { + return Condition.newBuilder() + .setFilter(filter) + .build(); + } +} diff --git a/src/main/java/io/qdrant/client/PointIdFactory.java b/src/main/java/io/qdrant/client/PointIdFactory.java new file mode 100644 index 00000000..ef5cad05 --- /dev/null +++ b/src/main/java/io/qdrant/client/PointIdFactory.java @@ -0,0 +1,31 @@ +package io.qdrant.client; + +import java.util.UUID; + +import static io.qdrant.client.grpc.Points.PointId; + +/** + * Convenience methods for constructing {@link PointId} + */ +public final class PointIdFactory { + private PointIdFactory() { + } + + /** + * Creates a point id from a {@link long} + * @param id The id + * @return a new instance of {@link PointId} + */ + public static PointId id(long id) { + return PointId.newBuilder().setNum(id).build(); + } + + /** + * Creates a point id from a {@link UUID} + * @param id The id + * @return a new instance of {@link PointId} + */ + public static PointId id(UUID id) { + return PointId.newBuilder().setUuid(id.toString()).build(); + } +} diff --git a/src/main/java/io/qdrant/client/QdrantClient.java b/src/main/java/io/qdrant/client/QdrantClient.java index 7bd73bab..680f29ed 100644 --- a/src/main/java/io/qdrant/client/QdrantClient.java +++ b/src/main/java/io/qdrant/client/QdrantClient.java @@ -1,1391 +1,2421 @@ package io.qdrant.client; -import io.grpc.Deadline; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import io.qdrant.client.grpc.Collections; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import io.qdrant.client.grpc.CollectionsGrpc; -import io.qdrant.client.grpc.JsonWithInt.Value; -import io.qdrant.client.grpc.Points; import io.qdrant.client.grpc.PointsGrpc; -import io.qdrant.client.grpc.QdrantGrpc; -import io.qdrant.client.grpc.QdrantOuterClass; import io.qdrant.client.grpc.SnapshotsGrpc; -import io.qdrant.client.grpc.SnapshotsService; -import io.qdrant.client.grpc.SnapshotsService.SnapshotDescription; -import io.qdrant.client.utils.PointUtil; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Path; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; import java.time.Duration; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; - -/** Client for interfacing with the Qdrant service. */ +import java.util.stream.Collectors; + +import static io.qdrant.client.grpc.Collections.AliasDescription; +import static io.qdrant.client.grpc.Collections.AliasOperations; +import static io.qdrant.client.grpc.Collections.ChangeAliases; +import static io.qdrant.client.grpc.Collections.CollectionDescription; +import static io.qdrant.client.grpc.Collections.CollectionInfo; +import static io.qdrant.client.grpc.Collections.CollectionOperationResponse; +import static io.qdrant.client.grpc.Collections.CreateAlias; +import static io.qdrant.client.grpc.Collections.CreateCollection; +import static io.qdrant.client.grpc.Collections.DeleteAlias; +import static io.qdrant.client.grpc.Collections.DeleteCollection; +import static io.qdrant.client.grpc.Collections.GetCollectionInfoRequest; +import static io.qdrant.client.grpc.Collections.GetCollectionInfoResponse; +import static io.qdrant.client.grpc.Collections.ListAliasesRequest; +import static io.qdrant.client.grpc.Collections.ListAliasesResponse; +import static io.qdrant.client.grpc.Collections.ListCollectionAliasesRequest; +import static io.qdrant.client.grpc.Collections.ListCollectionsRequest; +import static io.qdrant.client.grpc.Collections.ListCollectionsResponse; +import static io.qdrant.client.grpc.Collections.PayloadIndexParams; +import static io.qdrant.client.grpc.Collections.PayloadSchemaType; +import static io.qdrant.client.grpc.Collections.RenameAlias; +import static io.qdrant.client.grpc.Collections.UpdateCollection; +import static io.qdrant.client.grpc.Collections.VectorParams; +import static io.qdrant.client.grpc.Collections.VectorParamsMap; +import static io.qdrant.client.grpc.Collections.VectorsConfig; +import static io.qdrant.client.grpc.JsonWithInt.Value; +import static io.qdrant.client.grpc.Points.BatchResult; +import static io.qdrant.client.grpc.Points.ClearPayloadPoints; +import static io.qdrant.client.grpc.Points.CountPoints; +import static io.qdrant.client.grpc.Points.CountResponse; +import static io.qdrant.client.grpc.Points.CreateFieldIndexCollection; +import static io.qdrant.client.grpc.Points.DeleteFieldIndexCollection; +import static io.qdrant.client.grpc.Points.DeletePayloadPoints; +import static io.qdrant.client.grpc.Points.DeletePointVectors; +import static io.qdrant.client.grpc.Points.DeletePoints; +import static io.qdrant.client.grpc.Points.FieldType; +import static io.qdrant.client.grpc.Points.Filter; +import static io.qdrant.client.grpc.Points.GetPoints; +import static io.qdrant.client.grpc.Points.GetResponse; +import static io.qdrant.client.grpc.Points.PointGroup; +import static io.qdrant.client.grpc.Points.PointId; +import static io.qdrant.client.grpc.Points.PointStruct; +import static io.qdrant.client.grpc.Points.PointVectors; +import static io.qdrant.client.grpc.Points.PointsIdsList; +import static io.qdrant.client.grpc.Points.PointsOperationResponse; +import static io.qdrant.client.grpc.Points.PointsSelector; +import static io.qdrant.client.grpc.Points.ReadConsistency; +import static io.qdrant.client.grpc.Points.RecommendBatchPoints; +import static io.qdrant.client.grpc.Points.RecommendBatchResponse; +import static io.qdrant.client.grpc.Points.RecommendGroupsResponse; +import static io.qdrant.client.grpc.Points.RecommendPointGroups; +import static io.qdrant.client.grpc.Points.RecommendPoints; +import static io.qdrant.client.grpc.Points.RecommendResponse; +import static io.qdrant.client.grpc.Points.RetrievedPoint; +import static io.qdrant.client.grpc.Points.ScoredPoint; +import static io.qdrant.client.grpc.Points.ScrollPoints; +import static io.qdrant.client.grpc.Points.ScrollResponse; +import static io.qdrant.client.grpc.Points.SearchBatchPoints; +import static io.qdrant.client.grpc.Points.SearchBatchResponse; +import static io.qdrant.client.grpc.Points.SearchGroupsResponse; +import static io.qdrant.client.grpc.Points.SearchPointGroups; +import static io.qdrant.client.grpc.Points.SearchPoints; +import static io.qdrant.client.grpc.Points.SearchResponse; +import static io.qdrant.client.grpc.Points.SetPayloadPoints; +import static io.qdrant.client.grpc.Points.UpdatePointVectors; +import static io.qdrant.client.grpc.Points.UpdateResult; +import static io.qdrant.client.grpc.Points.UpsertPoints; +import static io.qdrant.client.grpc.Points.VectorsSelector; +import static io.qdrant.client.grpc.Points.WithPayloadSelector; +import static io.qdrant.client.grpc.Points.WithVectorsSelector; +import static io.qdrant.client.grpc.Points.WriteOrdering; +import static io.qdrant.client.grpc.Points.WriteOrderingType; +import static io.qdrant.client.grpc.QdrantGrpc.QdrantFutureStub; +import static io.qdrant.client.grpc.QdrantOuterClass.HealthCheckReply; +import static io.qdrant.client.grpc.QdrantOuterClass.HealthCheckRequest; +import static io.qdrant.client.grpc.SnapshotsService.CreateFullSnapshotRequest; +import static io.qdrant.client.grpc.SnapshotsService.CreateSnapshotRequest; +import static io.qdrant.client.grpc.SnapshotsService.CreateSnapshotResponse; +import static io.qdrant.client.grpc.SnapshotsService.DeleteFullSnapshotRequest; +import static io.qdrant.client.grpc.SnapshotsService.DeleteSnapshotRequest; +import static io.qdrant.client.grpc.SnapshotsService.DeleteSnapshotResponse; +import static io.qdrant.client.grpc.SnapshotsService.ListFullSnapshotsRequest; +import static io.qdrant.client.grpc.SnapshotsService.ListSnapshotsRequest; +import static io.qdrant.client.grpc.SnapshotsService.ListSnapshotsResponse; +import static io.qdrant.client.grpc.SnapshotsService.SnapshotDescription; + +/** + * Client for the Qdrant vector database. + */ public class QdrantClient implements AutoCloseable { - private QdrantGrpc.QdrantBlockingStub qdrantStub; - private CollectionsGrpc.CollectionsBlockingStub collectionsStub; - private PointsGrpc.PointsBlockingStub pointsStub; - private SnapshotsGrpc.SnapshotsBlockingStub snapshotsStub; - private ManagedChannel channel; - - /** - * Constructs a new QdrantClient with the specified URL and API key
- * Uses TLS if the URL is https, otherwise uses plaintext. - * - * @param url The URL of the Qdrant service. - * @param apiKey The API key for authentication. - * @throws MalformedURLException If the URL is malformed. - * @throws IllegalArgumentException If the protocol is invalid. - */ - public QdrantClient(String url, String apiKey) - throws MalformedURLException, IllegalArgumentException { - TokenInterceptor interceptor = new TokenInterceptor(apiKey); - ManagedChannel channel = createManagedChannel(url, interceptor); - initializeStubs(channel, null); - } - - /** - * Constructs a new QdrantClient with the specified URL and API key
- * Uses TLS if the URL is https, otherwise uses plaintext. - * - * @param url The URL of the Qdrant service. - * @param apiKey The API key for authentication. - * @param timeout The timeout for the gRPC requests. - * @throws MalformedURLException If the URL is malformed. - * @throws IllegalArgumentException If the protocol is invalid. - */ - public QdrantClient(String url, String apiKey, Duration timeout) - throws MalformedURLException, IllegalArgumentException { - TokenInterceptor interceptor = new TokenInterceptor(apiKey); - ManagedChannel channel = createManagedChannel(url, interceptor); - initializeStubs(channel, timeout); - } - - /** - * Constructs a new QdrantClient with the specified URL
- * Uses TLS if the URL is https, otherwise uses plaintext. - * - * @param url the URL of the Qdrant service - * @throws MalformedURLException If the URL is malformed - * @throws IllegalArgumentException If the protocol is invalid. - */ - public QdrantClient(String url) throws MalformedURLException, IllegalArgumentException { - ManagedChannel channel = createManagedChannel(url, null); - initializeStubs(channel, null); - } - - /** - * Constructs a new QdrantClient with the specified URL
- * Uses TLS if the URL is https, otherwise uses plaintext. - * - * @param url the URL of the Qdrant service - * @param timeout The timeout for the gRPC requests. - * @throws MalformedURLException If the URL is malformed - * @throws IllegalArgumentException If the protocol is invalid. - */ - public QdrantClient(String url, Duration timeout) - throws MalformedURLException, IllegalArgumentException { - ManagedChannel channel = createManagedChannel(url, null); - initializeStubs(channel, timeout); - } - - /** - * Creates a managed channel based on the provided URL and interceptor. - * - * @param url The URL of the gRPC server. - * @param interceptor The token interceptor to be added to the channel. - * @return The created managed channel. - * @throws MalformedURLException If the provided URL is malformed. - * @throws IllegalArgumentException If the provided protocol is invalid. - */ - private ManagedChannel createManagedChannel(String url, @Nullable TokenInterceptor interceptor) - throws MalformedURLException, IllegalArgumentException { - URL parsedUrl = new URL(url); - - ManagedChannelBuilder channelBuilder = - ManagedChannelBuilder.forAddress(parsedUrl.getHost(), parsedUrl.getPort()); - - switch (parsedUrl.getProtocol().toUpperCase()) { - case "HTTPS": - // TLS is enabled by default - // Specifying explicitly for clarity - channelBuilder.useTransportSecurity(); - break; - case "HTTP": - channelBuilder.usePlaintext(); - break; - default: - throw new IllegalArgumentException( - "Invalid protocol. Only 'http' and 'https' are supported for gRPC URLs."); - } - - if (interceptor != null) { - // Add token interceptor if apiKey is provided - channelBuilder.intercept(interceptor); - } - - return channelBuilder.build(); - } - - /** - * Initializes the gRPC stubs for Qdrant client. - * - * @param channel The managed channel used for communication. - */ - private void initializeStubs(ManagedChannel channel, @Nullable Duration timeout) { - this.qdrantStub = - QdrantGrpc.newBlockingStub(channel) - .withDeadline( - timeout == null ? null : Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS)); - this.collectionsStub = - CollectionsGrpc.newBlockingStub(channel) - .withDeadline( - timeout == null ? null : Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS)); - this.pointsStub = - PointsGrpc.newBlockingStub(channel) - .withDeadline( - timeout == null ? null : Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS)); - this.snapshotsStub = - SnapshotsGrpc.newBlockingStub(channel) - .withDeadline( - timeout == null ? null : Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS)); - this.channel = channel; - } - - /** - * Retrieves a list of collections. - * - * @return The response containing the list of collections. - */ - public Collections.ListCollectionsResponse listCollections() { - Collections.ListCollectionsRequest request = - Collections.ListCollectionsRequest.newBuilder().build(); - return collectionsStub.list(request); - } - - /** - * Performs a health check on the Qdrant service. - * - * @return The health check reply from the Qdrant service. - */ - public QdrantOuterClass.HealthCheckReply healthCheck() { - QdrantOuterClass.HealthCheckRequest request = - QdrantOuterClass.HealthCheckRequest.newBuilder().build(); - return qdrantStub.healthCheck(request); - } - - /** - * Checks if a collection with the given name exists. - * - * @param collectionName The name of the collection to check. - * @return True if the collection exists, false otherwise. - */ - public boolean hasCollection(String collectionName) { - return listCollections().getCollectionsList().stream() - .anyMatch(c -> c.getName().equals(collectionName)); - } - - /** - * Creates a new collection with the specified name, vector size, and distance metric. - * - * @param collectionName The name of the collection to be created. - * @param vectorSize The size of the vectors in the collection. - * @param distance The distance metric to be used for vector comparison. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse createCollection( - String collectionName, long vectorSize, Collections.Distance distance) { - Collections.VectorParams.Builder params = - Collections.VectorParams.newBuilder().setDistance(distance).setSize(vectorSize); - Collections.VectorsConfig config = - Collections.VectorsConfig.newBuilder().setParams(params).build(); - Collections.CreateCollection details = - Collections.CreateCollection.newBuilder() - .setVectorsConfig(config) - .setCollectionName(collectionName) - .build(); - return createCollection(details); - } - - /** - * Creates a new collection with the specified name, vector size, and distance metric. - * - * @param collectionName The name of the collection to be created. - * @param vectorsConfig The vectors configuration of the collection. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse createCollection( - String collectionName, Collections.VectorsConfig vectorsConfig) { - - Collections.CreateCollection details = - Collections.CreateCollection.newBuilder() - .setVectorsConfig(vectorsConfig) - .setCollectionName(collectionName) - .build(); - return createCollection(details); - } - - /** - * Creates a new collection with the specified details. - * - * @param details The details of the collection to be created. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse createCollection( - Collections.CreateCollection details) { - return collectionsStub.create(details); - } - - /** - * Deletes and creates a new collection with the specified name, vector size, and distance metric. - * - * @param collectionName The name of the collection to be created. - * @param vectorSize The size of the vectors in the collection. - * @param distance The distance metric to be used for vector comparison. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse recreateCollection( - String collectionName, long vectorSize, Collections.Distance distance) { - - Collections.VectorParams.Builder params = - Collections.VectorParams.newBuilder().setDistance(distance).setSize(vectorSize); - Collections.VectorsConfig config = - Collections.VectorsConfig.newBuilder().setParams(params).build(); - Collections.CreateCollection details = - Collections.CreateCollection.newBuilder() - .setVectorsConfig(config) - .setCollectionName(collectionName) - .build(); - return recreateCollection(details); - } - - /** - * Deletes and creates a new collection with the specified details. - * - * @param details The details of the collection to be created. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse recreateCollection( - Collections.CreateCollection details) { - deleteCollection(details.getCollectionName()); - return collectionsStub.create(details); - } - - /** - * Updates a collection with the specified details. - * - * @param details The details of the update operation. - * @return The response containing the operation status. - */ - public Collections.CollectionOperationResponse updateCollection( - Collections.UpdateCollection details) { - return collectionsStub.update(details); - } - - /** - * Deletes a collection with the specified name. - * - * @param collectionName the name of the collection to be deleted - * @return the response of the collection deletion operation - */ - public Collections.CollectionOperationResponse deleteCollection(String collectionName) { - Collections.DeleteCollection request = - Collections.DeleteCollection.newBuilder().setCollectionName(collectionName).build(); - return collectionsStub.delete(request); - } - - /** - * Retrieves information about a collection. - * - * @param collectionName The name of the collection. - * @return The response containing the collection information. - */ - public Collections.GetCollectionInfoResponse getCollectionInfo(String collectionName) { - Collections.GetCollectionInfoRequest request = - Collections.GetCollectionInfoRequest.newBuilder().setCollectionName(collectionName).build(); - return collectionsStub.get(request); - } - - /** - * Creates an alias for a collection. - * - * @param collectionName The name of the collection. - * @param aliasName The name of the alias. - * @return The response of the collection operation. - */ - public Collections.CollectionOperationResponse createAlias( - String collectionName, String aliasName) { - Collections.CreateAlias createAlias = - Collections.CreateAlias.newBuilder() - .setCollectionName(collectionName) - .setAliasName(aliasName) - .build(); - Collections.AliasOperations operations = - Collections.AliasOperations.newBuilder().setCreateAlias(createAlias).build(); - Collections.ChangeAliases changeAliases = - Collections.ChangeAliases.newBuilder().addActions(operations).build(); - - return this.updateAliases(changeAliases); - } - - /** - * Deletes an alias with the specified name. - * - * @param aliasName the name of the alias to be deleted - * @return the response of the collection operation - */ - public Collections.CollectionOperationResponse deleteAlias(String aliasName) { - Collections.DeleteAlias deleteAlias = - Collections.DeleteAlias.newBuilder().setAliasName(aliasName).build(); - Collections.AliasOperations operations = - Collections.AliasOperations.newBuilder().setDeleteAlias(deleteAlias).build(); - Collections.ChangeAliases changeAliases = - Collections.ChangeAliases.newBuilder().addActions(operations).build(); - - return this.updateAliases(changeAliases); - } - - /** - * Renames an alias in the Qdrant collection. - * - * @param oldAliasName The current name of the alias. - * @param newAliasName The new name for the alias. - * @return The response containing the result of the alias rename operation. - */ - public Collections.CollectionOperationResponse renameAlias( - String oldAliasName, String newAliasName) { - Collections.RenameAlias renameAlias = - Collections.RenameAlias.newBuilder() - .setOldAliasName(oldAliasName) - .setNewAliasName(newAliasName) - .build(); - Collections.AliasOperations operations = - Collections.AliasOperations.newBuilder().setRenameAlias(renameAlias).build(); - Collections.ChangeAliases changeAliases = - Collections.ChangeAliases.newBuilder().addActions(operations).build(); - return this.updateAliases(changeAliases); - } - - /** - * Updates the aliases for collections. - * - * @param details The details of the aliases to be changed. - * @return The response of the collection operation. - */ - public Collections.CollectionOperationResponse updateAliases(Collections.ChangeAliases details) { - return collectionsStub.updateAliases(details); - } - - /** - * Retrieves the list of aliases for a given collection. - * - * @param collectionName The name of the collection. - * @return The response containing the list of aliases. - */ - public Collections.ListAliasesResponse listCollectionAliases(String collectionName) { - Collections.ListCollectionAliasesRequest request = - Collections.ListCollectionAliasesRequest.newBuilder() - .setCollectionName(collectionName) - .build(); - return collectionsStub.listCollectionAliases(request); - } - - /** - * Retrieves a list of aliases. - * - * @return The response containing the list of aliases. - */ - public Collections.ListAliasesResponse listAliases() { - Collections.ListAliasesRequest request = Collections.ListAliasesRequest.newBuilder().build(); - return collectionsStub.listAliases(request); - } - - /** - * Retrieves the cluster information for a specific collection. - * - * @param collectionName The name of the collection. - * @return The cluster information for the collection. - */ - public Collections.CollectionClusterInfoResponse getCollectionClusterInfo(String collectionName) { - Collections.CollectionClusterInfoRequest request = - Collections.CollectionClusterInfoRequest.newBuilder() - .setCollectionName(collectionName) - .build(); - return collectionsStub.collectionClusterInfo(request); - } - - /** - * Updates the cluster setup for a collection. - * - * @param collectionName The name of the collection. - * @param request The request object containing the updated cluster setup. - * @return The response object indicating the success or failure of the update operation. - */ - public Collections.UpdateCollectionClusterSetupResponse updateCollectionClusterSetup( - String collectionName, Collections.UpdateCollectionClusterSetupRequest request) { - return collectionsStub.updateCollectionClusterSetup(request); - } - - /** Internal batch update method */ - private Points.UpdateBatchResponse batchUpdate( - String collectionName, - List operations, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.UpdateBatchPoints.Builder request = - Points.UpdateBatchPoints.newBuilder() - .setCollectionName(collectionName) - .setWait(wait) - .addAllOperations(operations); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.updateBatch(request.build()); - } - - /** - * Performs a batch update operation on a collection. Does not wait for the operation to complete - * before returning. - * - * @param collectionName The name of the collection. - * @param operations The list of update operations to be performed. - * @return The response of the batch update operation. - */ - public Points.UpdateBatchResponse batchUpdate( - String collectionName, - List operations, - @Nullable Points.WriteOrderingType ordering) { - return batchUpdate(collectionName, operations, ordering, false); - } - - /** - * Performs a batch update operation on a collection. Waits for the operation to complete before - * returning. - * - * @param collectionName The name of the collection. - * @param operations The list of update operations to be performed. - * @return The response of the batch update operation. - */ - public Points.UpdateBatchResponse batchUpdateBlocking( - String collectionName, - List operations, - @Nullable Points.WriteOrderingType ordering) { - return batchUpdate(collectionName, operations, ordering, true); - } - - /** Internal upsert method */ - private Points.PointsOperationResponse upsertPoints( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.UpsertPoints.Builder request = - Points.UpsertPoints.newBuilder() - .setCollectionName(collectionName) - .addAllPoints(points) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.upsert(request.build()); - } - - /** - * Upserts the given points into the specified collection. Does not wait for the operation to - * complete before returning. - * - * @param collectionName The name of the collection. - * @param points The list of points to be upserted. - * @param ordering The write ordering for the upsert operation. - * @return The response of the upsert operation. - */ - public Points.PointsOperationResponse upsertPoints( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering) { - return upsertPoints(collectionName, points, ordering, false); - } - - /** - * Upserts the given points into the specified collection. Waits for the operation to complete - * before returning. - * - * @param collectionName The name of the collection. - * @param points The list of points to be upserted. - * @param ordering The write ordering for the upsert operation. - * @return The response of the upsert operation. - */ - public Points.PointsOperationResponse upsertPointsBlocking( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering) { - return upsertPoints(collectionName, points, ordering, true); - } - - /** Internal batch upsert method */ - private Points.PointsOperationResponse upsertPointsBatch( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering, - Boolean wait, - int chunkSize) { - int listSize = points.size(); - double timeTaken = 0; - Points.UpdateResult result = null; - - for (int i = 0; i < listSize; i += chunkSize) { - int end = Math.min(i + chunkSize, listSize); - List chunk = points.subList(i, end); - Points.PointsOperationResponse response = upsertPoints(collectionName, chunk, ordering, wait); - timeTaken += response.getTime(); - result = response.getResult(); - } - return Points.PointsOperationResponse.newBuilder().setTime(timeTaken).setResult(result).build(); - } - - /** - * Upserts a batch of points in the specified collection. Does not wait for the operation to - * complete before returning. - * - * @param collectionName The name of the collection. - * @param points The list of points to upsert. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse upsertPointsBatch( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering, - int chunkSize) { - return upsertPointsBatch(collectionName, points, ordering, false, chunkSize); - } - - /** - * Upserts a batch of points in the specified collection. Waits for the operation to complete - * before returning. - * - * @param collectionName The name of the collection. - * @param points The list of points to upsert. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse upsertPointsBatchBlocking( - String collectionName, - List points, - @Nullable Points.WriteOrderingType ordering, - int chunkSize) { - return upsertPointsBatch(collectionName, points, ordering, true, chunkSize); - } - - /** Internal update method */ - private Points.PointsOperationResponse setPayload( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.SetPayloadPoints.Builder request = - Points.SetPayloadPoints.newBuilder() - .setCollectionName(collectionName) - .setPointsSelector(points) - .putAllPayload(payload) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.setPayload(request.build()); - } - - /** - * Sets the payload of the specified points in a collection. Does not wait for the operation to - * complete before returning. - * - * @param collectionName The name of the collection. - * @param points The selector for the points to be updated. - * @param payload The new payload to be assigned to the points. - * @param ordering The ordering of the write operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse setPayload( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering) { - return setPayload(collectionName, points, payload, ordering, false); - } - - /** - * Sets the payload of the specified points in a collection. Waits for the operation to complete - * before returning. - * - * @param collectionName The name of the collection. - * @param points The selector for the points to be updated. - * @param payload The new payload to be assigned to the points. - * @param ordering The ordering of the write operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse setPayloadBlocking( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering) { - return setPayload(collectionName, points, payload, ordering, true); - } - - /** Internal payload overwrite method */ - private Points.PointsOperationResponse overwritePayload( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.SetPayloadPoints.Builder request = - Points.SetPayloadPoints.newBuilder() - .setCollectionName(collectionName) - .setPointsSelector(points) - .putAllPayload(payload) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.overwritePayload(request.build()); - } - - /** - * Overwrites the payload of the specified points in a collection. Does not wait for the operation - * to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The selector for the points to be overwritten. - * @param payload The new payload to be assigned to the points. - * @param ordering The ordering of the write operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse overwritePayload( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering) { - return overwritePayload(collectionName, points, payload, ordering, false); - } - - /** - * Overwrites the payload of the specified points in a collection. Waits for the operation to - * complete before returning. - * - * @param collectionName The name of the collection. - * @param points The selector for the points to be overwritten. - * @param payload The new payload to be assigned to the points. - * @param ordering The ordering of the write operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse overwritePayloadBlocking( - String collectionName, - Points.PointsSelector points, - Map payload, - @Nullable Points.WriteOrderingType ordering) { - return overwritePayload(collectionName, points, payload, ordering, true); - } - - /** Internal payload delete method */ - private Points.PointsOperationResponse deletePayload( - String collectionName, - Points.PointsSelector points, - List keys, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.DeletePayloadPoints.Builder request = - Points.DeletePayloadPoints.newBuilder() - .setCollectionName(collectionName) - .addAllKeys(keys) - .setWait(wait) - .setPointsSelector(points); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.deletePayload(request.build()); - } - - /** - * Deletes the payload associated with the specified collection, points, keys, and ordering. Does - * not wait for the operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The points selector. - * @param keys The list of keys. - * @param ordering The write ordering. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse deletePayload( - String collectionName, - Points.PointsSelector points, - List keys, - @Nullable Points.WriteOrderingType ordering) { - return deletePayload(collectionName, points, keys, ordering, false); - } - - /** - * Deletes the payload associated with the specified collection, points, keys, and ordering. Waits - * for the operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The points selector. - * @param keys The list of keys. - * @param ordering The write ordering. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse deletePayloadBlocking( - String collectionName, - Points.PointsSelector points, - List keys, - @Nullable Points.WriteOrderingType ordering) { - return deletePayload(collectionName, points, keys, ordering, true); - } - - /** Internal payload clear method */ - private Points.PointsOperationResponse clearPayload( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.ClearPayloadPoints.Builder request = - Points.ClearPayloadPoints.newBuilder() - .setCollectionName(collectionName) - .setPoints(points) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - - return pointsStub.clearPayload(request.build()); - } - - /** - * Clears the payload associated with the specified collection, points and ordering. Does not wait - * for the operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The points to be cleared. - * @return The response of the clearPayload operation. - */ - public Points.PointsOperationResponse clearPayload( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering) { - return clearPayload(collectionName, points, ordering, false); - } - - /** - * Clears the payload associated with the specified collection, points and ordering. Waits for the - * operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The points to be cleared. - * @return The response of the clearPayload operation. - */ - public Points.PointsOperationResponse clearPayloadBlocking( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering) { - return clearPayload(collectionName, points, ordering, true); - } - - /** - * Retrieves points from a collection. - * - * @param collectionName The name of the collection. - * @param points The IDs of the points to retrieve. - * @param withVectors The selector for including vectors in the response. - * @param withPayload The selector for including payload in the response. - * @param readConsistency The read consistency level for the operation. - * @return The response containing the retrieved points. - */ - public Points.GetResponse getPoints( - String collectionName, - Iterable points, - Points.WithVectorsSelector withVectors, - Points.WithPayloadSelector withPayload, - @Nullable Points.ReadConsistencyType readConsistency) { - Points.GetPoints.Builder request = - Points.GetPoints.newBuilder() - .setCollectionName(collectionName) - .addAllIds(points) - .setWithVectors(withVectors) - .setWithPayload(withPayload); - - if (readConsistency != null) { - request.setReadConsistency(PointUtil.consistency(readConsistency)); - } - - return pointsStub.get(request.build()); - } - - /** - * Performs a search operation on the points. - * - * @param request The search request containing the query parameters. - * @return The response containing the search results. - */ - public Points.SearchResponse searchPoints(Points.SearchPoints request) { - return pointsStub.search(request); - } - - /** - * Performs a batch search for points. - * - * @param request The search request containing the batch points to search for. - * @return The response containing the search results. - */ - public Points.SearchBatchResponse searchBatchPoints(Points.SearchBatchPoints request) { - return pointsStub.searchBatch(request); - } - - /** - * Searches for point groups based on the given request. - * - * @param request The search request containing the criteria for searching point groups. - * @return The response containing the search results for point groups. - */ - public Points.SearchGroupsResponse searchGroups(Points.SearchPointGroups request) { - return pointsStub.searchGroups(request); - } - - /** Internal delete method */ - private Points.PointsOperationResponse deletePoints( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.DeletePoints.Builder request = - Points.DeletePoints.newBuilder() - .setCollectionName(collectionName) - .setPoints(points) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.delete(request.build()); - } - - /** - * Deletes points from a collection. Does not wait for the operation to complete before returning. - * - * @param collectionName The name of the collection from which points will be deleted. - * @param points The selector for the points to be deleted. - * @param ordering The ordering of the write operation. - * @return The response of the points deletion operation. - */ - public Points.PointsOperationResponse deletePoints( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering) { - return deletePoints(collectionName, points, ordering, false); - } - - /** - * Deletes points from a collection. Waits for the operation to complete before returning. - * - * @param collectionName The name of the collection from which points will be deleted. - * @param points The selector for the points to be deleted. - * @param ordering The ordering of the write operation. - * @return The response of the points deletion operation. - */ - public Points.PointsOperationResponse deletePointsBlocking( - String collectionName, - Points.PointsSelector points, - @Nullable Points.WriteOrderingType ordering) { - return deletePoints(collectionName, points, ordering, true); - } - - /** Internal delete vectors method */ - private Points.PointsOperationResponse deleteVectors( - String collectionName, - Points.PointsSelector points, - Points.VectorsSelector vectors, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.DeletePointVectors.Builder requests = - Points.DeletePointVectors.newBuilder() - .setCollectionName(collectionName) - .setPointsSelector(points) - .setVectors(vectors) - .setWait(wait); - - if (ordering != null) { - requests.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.deleteVectors(requests.build()); - } - - /** - * Deletes vectors from a collection. Does not wait for the operation to complete before - * returning. - * - * @param collectionName The name of the collection. - * @param points The selector for points to delete. - * @param vectors The selector for vectors to delete. - * @param ordering The write ordering for the operation. - * @return The response of the delete operation. - */ - public Points.PointsOperationResponse deleteVectors( - String collectionName, - Points.PointsSelector points, - Points.VectorsSelector vectors, - @Nullable Points.WriteOrderingType ordering) { - return deleteVectors(collectionName, points, vectors, ordering, false); - } - - /** - * Deletes vectors from a collection. Waits for the operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param points The selector for points to delete. - * @param vectors The selector for vectors to delete. - * @param ordering The write ordering for the operation. - * @return The response of the delete operation. - */ - public Points.PointsOperationResponse deleteVectorsBlocking( - String collectionName, - Points.PointsSelector points, - Points.VectorsSelector vectors, - @Nullable Points.WriteOrderingType ordering) { - return deleteVectors(collectionName, points, vectors, ordering, true); - } - - /** Internal update vectors method */ - private Points.PointsOperationResponse updateVectors( - String collectionName, - Iterable points, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.UpdatePointVectors.Builder request = - Points.UpdatePointVectors.newBuilder() - .setCollectionName(collectionName) - .addAllPoints(points) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.updateVectors(request.build()); - } - - /** - * Updates the vectors of points in a collection. Does not wait for the operation to complete - * before returning. - * - * @param collectionName The name of the collection. - * @param points An iterable of point vectors to update. - * @param ordering The write ordering for the update operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse updateVectors( - String collectionName, - Iterable points, - @Nullable Points.WriteOrderingType ordering) { - return updateVectors(collectionName, points, ordering, false); - } - - /** - * Updates the vectors of points in a collection. Waits for the operation to complete before - * returning. - * - * @param collectionName The name of the collection. - * @param points An iterable of point vectors to update. - * @param ordering The write ordering for the update operation. - * @return The response of the points operation. - */ - public Points.PointsOperationResponse updateVectorsBlocking( - String collectionName, - Iterable points, - @Nullable Points.WriteOrderingType ordering) { - return updateVectors(collectionName, points, ordering, true); - } - - /** - * Retrieve points from a collection based on filters. - * - * @param request The search request containing the query parameters. - * @return The response containing the scroll results. - */ - public Points.ScrollResponse scroll(Points.ScrollPoints request) { - return pointsStub.scroll(request); - } - - /** - * Recommends points based on the given positive/negative points recommendation request. - * - * @param request The points recommendation request. - * @return The recommendation response. - */ - public Points.RecommendResponse recommend(Points.RecommendPoints request) { - return pointsStub.recommend(request); - } - - /** - * Recommends points batch based on the given positive/negative points recommendation request. - * - * @param request The batch recommendation points request. - * @return The response containing the recommended points. - */ - public Points.RecommendBatchResponse recommendBatch(Points.RecommendBatchPoints request) { - return pointsStub.recommendBatch(request); - } - - /** - * Recommends groups based on the given positive/negative points recommendation request. - * - * @param request The request containing the point groups to recommend. - * @return The response containing the recommended groups. - */ - public Points.RecommendGroupsResponse recommendGroups(Points.RecommendPointGroups request) { - return pointsStub.recommendGroups(request); - } - - /** - * Counts the number of points in a collection based on the given filters. - * - * @param collectionName The name of the collection. - * @param filter The filter to be applied. - * @return The response containing the points count result. - */ - public Points.CountResponse count(String collectionName, Points.Filter filter) { - Points.CountPoints request = - Points.CountPoints.newBuilder().setCollectionName(collectionName).setFilter(filter).build(); - return pointsStub.count(request); - } - - /** - * Counts the number of points in a collection based on the given filters. - * - * @param request The request containing the filters and options. - * @return The response containing the points count result. - */ - public Points.CountResponse count(Points.CountPoints request) { - return pointsStub.count(request); - } - - /** Internal update batch method */ - private Points.UpdateBatchResponse updateBatchPoints( - String collecionName, - Iterable operations, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.UpdateBatchPoints.Builder request = - Points.UpdateBatchPoints.newBuilder() - .setCollectionName(collecionName) - .addAllOperations(operations) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.updateBatch(request.build()); - } - - /** - * Updates a batch of points in a collection. Does not wait for the operation to complete before - * returning. - * - * @param collecionName The name of the collection. - * @param operations The operations to be performed on the points. - * @param ordering The ordering of the write operations. - * @return The response of the batch points update operation. - */ - public Points.UpdateBatchResponse updateBatchPoints( - String collecionName, - Iterable operations, - @Nullable Points.WriteOrderingType ordering) { - return updateBatchPoints(collecionName, operations, ordering, false); - } - - /** - * Updates a batch of points in a collection. Waits for the operation to complete before - * returning. - * - * @param collectionName The name of the collection. - * @param operations The operations to be performed on the points. - * @param ordering The ordering of the write operations. - * @return The response of the batch points update operation. - */ - public Points.UpdateBatchResponse updateBatchPointsBlocking( - String collectionName, - Iterable operations, - @Nullable Points.WriteOrderingType ordering) { - return updateBatchPoints(collectionName, operations, ordering, true); - } - - /** Internal create field index method */ - private Points.PointsOperationResponse createFieldIndex( - String collectionName, - String fieldName, - Points.FieldType fieldType, - Collections.PayloadIndexParams fieldIndexParams, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.CreateFieldIndexCollection.Builder request = - Points.CreateFieldIndexCollection.newBuilder() - .setCollectionName(collectionName) - .setFieldName(fieldName) - .setFieldType(fieldType) - .setFieldIndexParams(fieldIndexParams) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.createFieldIndex(request.build()); - } - - /** - * Creates a field index in the specified collection with the given parameters. Does not wait for - * the operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param fieldName The name of the field. - * @param fieldType The type of the field. - * @param fieldIndexParams The index parameters for the field. - * @param ordering The write ordering for the field. - * @return The response of the field index creation operation. - */ - public Points.PointsOperationResponse createFieldIndex( - String collectionName, - String fieldName, - Points.FieldType fieldType, - Collections.PayloadIndexParams fieldIndexParams, - @Nullable Points.WriteOrderingType ordering) { - return createFieldIndex( - collectionName, fieldName, fieldType, fieldIndexParams, ordering, false); - } - - /** - * Creates a field index in the specified collection with the given parameters. Waits for the - * operation to complete before returning. - * - * @param collectionName The name of the collection. - * @param fieldName The name of the field. - * @param fieldType The type of the field. - * @param fieldIndexParams The index parameters for the field. - * @param ordering The write ordering for the field. - * @return The response of the field index creation operation. - */ - public Points.PointsOperationResponse createFieldIndexBlocking( - String collectionName, - String fieldName, - Points.FieldType fieldType, - Collections.PayloadIndexParams fieldIndexParams, - @Nullable Points.WriteOrderingType ordering) { - return createFieldIndex(collectionName, fieldName, fieldType, fieldIndexParams, ordering, true); - } - - /** Internal delete field index method */ - private Points.PointsOperationResponse deleteFieldIndex( - String collectionName, - String fieldName, - @Nullable Points.WriteOrderingType ordering, - Boolean wait) { - Points.DeleteFieldIndexCollection.Builder request = - Points.DeleteFieldIndexCollection.newBuilder() - .setCollectionName(collectionName) - .setFieldName(fieldName) - .setWait(wait); - - if (ordering != null) { - request.setOrdering(PointUtil.ordering(ordering)); - } - return pointsStub.deleteFieldIndex(request.build()); - } - - /** - * Deletes the field index for a given collection and field name. Does not wait for the operation - * to complete before returning. - * - * @param collectionName The name of the collection. - * @param fieldName The name of the field. - * @param ordering The write ordering for the operation. - * @return The response of the delete operation. - */ - public Points.PointsOperationResponse deleteFieldIndex( - String collectionName, String fieldName, @Nullable Points.WriteOrderingType ordering) { - return deleteFieldIndex(collectionName, fieldName, ordering, false); - } - - /** - * Deletes the field index for a given collection and field name. Waits for the operation to - * complete before returning. - * - * @param collectionName The name of the collection. - * @param fieldName The name of the field. - * @param ordering The write ordering for the operation. - * @return The response of the delete operation. - */ - public Points.PointsOperationResponse deleteFieldIndexBlocking( - String collectionName, String fieldName, @Nullable Points.WriteOrderingType ordering) { - return deleteFieldIndex(collectionName, fieldName, ordering, true); - } - - /** - * Creates a snapshot of a collection. - * - * @param collectionName the name of the collection - * @return The response containing information about the created snapshot - */ - public SnapshotsService.CreateSnapshotResponse createSnapshot(String collectionName) { - SnapshotsService.CreateSnapshotRequest request = - SnapshotsService.CreateSnapshotRequest.newBuilder() - .setCollectionName(collectionName) - .build(); - return snapshotsStub.create(request); - } - - /** - * Retrieves a list of snapshots for a given collection. - * - * @param collectionName the name of the collection - * @return The response containing the list of snapshots - */ - public SnapshotsService.ListSnapshotsResponse listSnapshots(String collectionName) { - SnapshotsService.ListSnapshotsRequest request = - SnapshotsService.ListSnapshotsRequest.newBuilder() - .setCollectionName(collectionName) - .build(); - return snapshotsStub.list(request); - } - - /** - * Deletes a snapshot with the specified name from the given collection. - * - * @param collectionName The name of the collection. - * @param snapshotName The name of the snapshot to be deleted. - * @return The response indicating the success or failure of the snapshot deletion. - */ - public SnapshotsService.DeleteSnapshotResponse deleteSnapshot( - String collectionName, String snapshotName) { - SnapshotsService.DeleteSnapshotRequest request = - SnapshotsService.DeleteSnapshotRequest.newBuilder() - .setCollectionName(collectionName) - .setSnapshotName(snapshotName) - .build(); - return snapshotsStub.delete(request); - } - - /** - * Creates a full snapshot of the Qdrant database. - * - * @return The response indicating the status of the snapshot creation. - */ - public SnapshotsService.CreateSnapshotResponse createFullSnapshot() { - SnapshotsService.CreateFullSnapshotRequest request = - SnapshotsService.CreateFullSnapshotRequest.newBuilder().build(); - return snapshotsStub.createFull(request); - } - - /** - * Retrieves a list of full snapshots for a given collection. - * - * @return The response containing the list of full snapshots. - */ - public SnapshotsService.ListSnapshotsResponse listFullSnapshots() { - SnapshotsService.ListFullSnapshotsRequest request = - SnapshotsService.ListFullSnapshotsRequest.newBuilder().build(); - return snapshotsStub.listFull(request); - } - - /** - * Deletes a full snapshot. - * - * @param snapshotName the name of the snapshot to delete. - * @return The response indicating the status of the snapshot deletion. - */ - public SnapshotsService.DeleteSnapshotResponse deleteFullSnapshot(String snapshotName) { - SnapshotsService.DeleteFullSnapshotRequest request = - SnapshotsService.DeleteFullSnapshotRequest.newBuilder() - .setSnapshotName(snapshotName) - .build(); - return snapshotsStub.deleteFull(request); - } - - /** - * Downloads a snapshot of a collection from the specified REST API URI and saves it to the given - * output path. - * - * @param outPath The path where the snapshot will be saved. - * @param collectionName The name of the collection. - * @param snapshotName The name of the snapshot. If null, the latest snapshot will be downloaded. - * @param restApiUri The URI of the REST API. If null, the default URI "http://localhost:6333" - * will be used. - * @throws RuntimeException If an error occurs while downloading the snapshot. - */ - public void downloadSnapshot( - Path outPath, - String collectionName, - @Nullable String snapshotName, - @Nullable String restApiUri) { - try { - String resolvedSnapshotName; - - if (snapshotName != null) { - resolvedSnapshotName = snapshotName; - } else { - // Get the latest(0th) snapshot of the collection - List snapshots = - listSnapshots(collectionName).getSnapshotDescriptionsList(); - if (snapshots.isEmpty()) { - throw new RuntimeException("No snapshots found"); - } - resolvedSnapshotName = - listSnapshots(collectionName).getSnapshotDescriptionsList().get(0).getName(); - } - - String uri; - if (restApiUri != null) { - uri = - String.format( - "%s/collections/%s/snapshots/%s", restApiUri, collectionName, resolvedSnapshotName); - } else { - uri = - String.format( - "http://localhost:6333/collections/%s/snapshots/%s", - collectionName, resolvedSnapshotName); - } - - URL url = new URL(uri); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - - if (connection.getResponseCode() == 200) { - try (InputStream in = connection.getInputStream(); - FileOutputStream fileOut = new FileOutputStream(outPath.toFile())) { - - byte[] buffer = new byte[8192]; - int bytesRead; - while ((bytesRead = in.read(buffer)) != -1) { - fileOut.write(buffer, 0, bytesRead); - } - - System.out.println("Downloaded successfully"); - } - } else { - System.err.println("Download failed. HTTP Status Code: " + connection.getResponseCode()); - } - } catch (IOException e) { - throw new RuntimeException("Error downloading snapshot " + e.getMessage()); - } - } - - @Override - public void close() throws InterruptedException { - this.channel.shutdown().awaitTermination(10, TimeUnit.SECONDS); - } + private static final Logger logger = LoggerFactory.getLogger(QdrantClient.class); + private final QdrantGrpcClient grpcClient; + + /** + * Creates a new instance of {@link QdrantClient} + * + * @param grpcClient The low-level gRPC client to use. + */ + public QdrantClient(QdrantGrpcClient grpcClient) { + this.grpcClient = grpcClient; + } + + /** + * Gets detailed information about the qdrant cluster. + * + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture healthCheckAsync() { + return healthCheckAsync(null); + } + + /** + * Gets detailed information about the qdrant cluster. + * + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture healthCheckAsync(@Nullable Duration timeout) { + QdrantFutureStub qdrant = timeout != null + ? this.grpcClient.qdrant().withDeadlineAfter(timeout.toMillis(), TimeUnit.MILLISECONDS) + : this.grpcClient.qdrant(); + return qdrant.healthCheck(HealthCheckRequest.getDefaultInstance()); + } + + //region Collections + + /** + * Creates a new collection with the given parameters + * + * @param collectionName The name of the collection. + * @param vectorParams The vector parameters + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync( + String collectionName, + VectorParams vectorParams) { + return createCollectionAsync(collectionName, vectorParams, null); + } + + /** + * Creates a new collection with the given parameters + * + * @param collectionName The name of the collection. + * @param vectorParams The vector parameters + * @param timeout The timeout for the call + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync( + String collectionName, + VectorParams vectorParams, + @Nullable Duration timeout) { + return createCollectionAsync(CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParams(vectorParams) + .build()) + .build(), + timeout); + } + + /** + * Creates a new collection with the given parameters + * + * @param collectionName The name of the collection. + * @param namedVectorParams The named vector parameters + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync( + String collectionName, + Map namedVectorParams) { + return createCollectionAsync(collectionName, namedVectorParams, null); + } + + /** + * Creates a new collection with the given parameters + * + * @param collectionName The name of the collection. + * @param namedVectorParams The named vector parameters + * @param timeout The timeout for the call + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync( + String collectionName, + Map namedVectorParams, + @Nullable Duration timeout) { + return createCollectionAsync(CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParamsMap(VectorParamsMap.newBuilder().putAllMap(namedVectorParams).build()) + .build()) + .build(), + timeout); + } + + /** + * Creates a new collection with the given parameters + * + * @param createCollection The collection creation parameters + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync(CreateCollection createCollection) { + return createCollectionAsync(createCollection, null); + } + + /** + * Creates a new collection with the given parameters + * + * @param createCollection The collection creation parameters + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createCollectionAsync(CreateCollection createCollection, @Nullable Duration timeout) { + String collectionName = createCollection.getCollectionName(); + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Create collection '{}'", collectionName); + ListenableFuture future = getCollections(timeout).create(createCollection); + addLogFailureCallback(future, "Create collection"); + return Futures.transform(future, response -> { + if (!response.getResult()) { + logger.error("Collection '{}' could not be created", collectionName); + throw new QdrantException("Collection '" + collectionName + "' could not be created"); + } + return response; + }, MoreExecutors.directExecutor()); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param collectionName The name of the collection. + * @param vectorParams The vector parameters + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture recreateCollectionAsync( + String collectionName, + VectorParams vectorParams) { + return recreateCollectionAsync(collectionName, vectorParams, null); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param collectionName The name of the collection. + * @param vectorParams The vector parameters + * @param timeout The timeout for the call + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture recreateCollectionAsync( + String collectionName, + VectorParams vectorParams, + @Nullable Duration timeout) { + return recreateCollectionAsync(CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParams(vectorParams) + .build()) + .build(), + timeout); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param collectionName The name of the collection. + * @param namedVectorParams The named vector parameters + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture recreateCollectionAsync( + String collectionName, + Map namedVectorParams) { + return recreateCollectionAsync(collectionName, namedVectorParams, null); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param collectionName The name of the collection. + * @param namedVectorParams The named vector parameters + * @param timeout The timeout for the call + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture recreateCollectionAsync( + String collectionName, + Map namedVectorParams, + @Nullable Duration timeout) { + return recreateCollectionAsync(CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParamsMap(VectorParamsMap.newBuilder().putAllMap(namedVectorParams).build()) + .build()) + .build(), + timeout); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param createCollection The collection creation parameters + * @return a new instance of {@link CollectionOperationResponse} + */ + public ListenableFuture recreateCollectionAsync(CreateCollection createCollection) { + return recreateCollectionAsync(createCollection, null); + } + + /** + * Deletes a collection if one exists, and creates a new collection with the given parameters. + * + * @param createCollection The collection creation parameters + * @param timeout The timeout for the call. + * @return a new instance of {@link CollectionOperationResponse} + */ + public ListenableFuture recreateCollectionAsync(CreateCollection createCollection, @Nullable Duration timeout) { + return Futures.transformAsync( + deleteCollectionAsync(createCollection.getCollectionName(), timeout), + input -> createCollectionAsync(createCollection, timeout), + MoreExecutors.directExecutor()); + } + + /** + * Gets detailed information about an existing collection. + * + * @param collectionName The name of the collection. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture getCollectionInfoAsync(String collectionName) { + return getCollectionInfoAsync(collectionName, null); + } + + /** + * Gets detailed information about an existing collection. + * + * @param collectionName The name of the collection. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture getCollectionInfoAsync(String collectionName, @Nullable Duration timeout) { + logger.debug("Get collection info for '{}'", collectionName); + GetCollectionInfoRequest request = GetCollectionInfoRequest.newBuilder() + .setCollectionName(collectionName) + .build(); + ListenableFuture future = getCollections(timeout).get(request); + addLogFailureCallback(future, "Get collection info"); + return Futures.transform(future, GetCollectionInfoResponse::getResult, MoreExecutors.directExecutor()); + } + + /** + * Deletes a collection and all its associated data. + * + * @param collectionName The name of the collection + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteCollectionAsync(String collectionName) { + return deleteCollectionAsync(collectionName, null); + } + + /** + * Deletes a collection and all its associated data. + * + * @param collectionName The name of the collection + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteCollectionAsync(String collectionName, @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Delete collection '{}'", collectionName); + + DeleteCollection deleteCollection = DeleteCollection.newBuilder() + .setCollectionName(collectionName) + .build(); + ListenableFuture future = getCollections(timeout).delete(deleteCollection); + addLogFailureCallback(future, "Delete collection"); + + return Futures.transform(future, response -> { + if (!response.getResult()) { + logger.error("Collection '{}' could not be deleted", collectionName); + throw new QdrantException("Collection '" + collectionName + "' could not be deleted"); + } + return response; + }, MoreExecutors.directExecutor()); + } + + /** + * Gets the names of all existing collections + * + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listCollectionsAsync() { + return listCollectionsAsync(null); + } + + /** + * Gets the names of all existing collections + * + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listCollectionsAsync(@Nullable Duration timeout) { + logger.debug("List collections"); + + ListenableFuture future = + getCollections(timeout).list(ListCollectionsRequest.getDefaultInstance()); + + addLogFailureCallback(future, "List collection"); + return Futures.transform(future, response -> + response.getCollectionsList() + .stream() + .map(CollectionDescription::getName) + .collect(Collectors.toList()), MoreExecutors.directExecutor()); + } + + /** + * Update parameters of the collection + * + * @param updateCollection The update parameters. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateCollectionAsync(UpdateCollection updateCollection) { + return updateCollectionAsync(updateCollection, null); + } + + /** + * Update parameters of the collection + * + * @param updateCollection The update parameters. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateCollectionAsync(UpdateCollection updateCollection, @Nullable Duration timeout) { + String collectionName = updateCollection.getCollectionName(); + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Update collection '{}'", collectionName); + + ListenableFuture future = getCollections(timeout).update(updateCollection); + addLogFailureCallback(future, "Update collection"); + return Futures.transform(future, response -> { + if (!response.getResult()) { + logger.error("Collection '{}' could not be updated", collectionName); + throw new QdrantException("Collection '" + collectionName + "' could not be updated"); + } + return response; + }, MoreExecutors.directExecutor()); + } + + //endregion + + //region Alias Management + + /** + * Creates an alias for a given collection. + * + * @param aliasName The alias to be created. + * @param collectionName The collection for which the alias is to be created. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createAliasAsync(String aliasName, String collectionName) { + return createAliasAsync(aliasName, collectionName, null); + } + + /** + * Creates an alias for a given collection. + * + * @param aliasName The alias to be created. + * @param collectionName The collection for which the alias is to be created. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createAliasAsync(String aliasName, String collectionName, @Nullable Duration timeout) { + return updateAliasesAsync(ImmutableList.of(AliasOperations.newBuilder() + .setCreateAlias(CreateAlias.newBuilder() + .setAliasName(aliasName) + .setCollectionName(collectionName) + .build()) + .build()), + timeout); + } + + /** + * Renames an existing alias. + * + * @param oldAliasName The old alias name. + * @param newAliasName The new alias name. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture renameAliasAsync(String oldAliasName, String newAliasName) { + return renameAliasAsync(oldAliasName, newAliasName, null); + } + + /** + * Renames an existing alias. + * + * @param oldAliasName The old alias name. + * @param newAliasName The new alias name. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture renameAliasAsync(String oldAliasName, String newAliasName, @Nullable Duration timeout) { + return updateAliasesAsync(ImmutableList.of(AliasOperations.newBuilder() + .setRenameAlias(RenameAlias.newBuilder() + .setOldAliasName(oldAliasName) + .setNewAliasName(newAliasName) + .build()) + .build()), + timeout); + } + + /** + * Deletes an alias. + * + * @param aliasName The alias to be deleted. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAliasAsync(String aliasName) { + return deleteAliasAsync(aliasName, null); + } + + /** + * Deletes an alias. + * + * @param aliasName The alias to be deleted. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAliasAsync(String aliasName, @Nullable Duration timeout) { + return updateAliasesAsync(ImmutableList.of(AliasOperations.newBuilder() + .setDeleteAlias(DeleteAlias.newBuilder() + .setAliasName(aliasName) + .build()) + .build()), + timeout); + } + + /** + * Update the aliases of existing collections. + * + * @param aliasOperations The list of operations to perform. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateAliasesAsync(List aliasOperations) { + return updateAliasesAsync(aliasOperations, null); + } + + /** + * Update the aliases of existing collections. + * + * @param aliasOperations The list of operations to perform. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateAliasesAsync(List aliasOperations, @Nullable Duration timeout) { + ChangeAliases request = ChangeAliases.newBuilder() + .addAllActions(aliasOperations) + .build(); + + if (logger.isDebugEnabled()) { + for (AliasOperations aliasOperation : aliasOperations) { + switch (aliasOperation.getActionCase()) { + case CREATE_ALIAS: + CreateAlias createAlias = aliasOperation.getCreateAlias(); + logger.debug("Create alias '{}' for collection '{}'", + createAlias.getAliasName(), + createAlias.getCollectionName()); + break; + case RENAME_ALIAS: + RenameAlias renameAlias = aliasOperation.getRenameAlias(); + logger.debug("Rename alias '{}' to '{}'", + renameAlias.getOldAliasName(), + renameAlias.getNewAliasName()); + break; + case DELETE_ALIAS: + DeleteAlias deleteAlias = aliasOperation.getDeleteAlias(); + logger.debug("Delete alias '{}'", deleteAlias.getAliasName()); + break; + case ACTION_NOT_SET: + break; + } + } + } + + ListenableFuture future = getCollections(timeout).updateAliases(request); + addLogFailureCallback(future, "Update aliases"); + return Futures.transform(future, response -> { + if (!response.getResult()) { + logger.error("Alias update operation could not be performed"); + throw new QdrantException("Alias update could not be performed"); + } + return response; + }, MoreExecutors.directExecutor()); + } + + /** + * Gets a list of all aliases for a collection. + * + * @param collectionName The name of the collection. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listCollectionAliasesAsync(String collectionName) { + return listCollectionAliasesAsync(collectionName, null); + } + + /** + * Gets a list of all aliases for a collection. + * + * @param collectionName The name of the collection. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listCollectionAliasesAsync(String collectionName, @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("List aliases for collection '{}'", collectionName); + + ListCollectionAliasesRequest request = ListCollectionAliasesRequest.newBuilder() + .setCollectionName(collectionName) + .build(); + + ListenableFuture future = getCollections(timeout).listCollectionAliases(request); + addLogFailureCallback(future, "List collection aliases"); + return Futures.transform(future, response -> response.getAliasesList() + .stream() + .map(AliasDescription::getAliasName) + .collect(Collectors.toList()), MoreExecutors.directExecutor()); + } + + /** + * Gets a list of all aliases for all existing collections. + * + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listAliasesAsync() { + return listAliasesAsync(null); + } + + /** + * Gets a list of all aliases for all existing collections. + * + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listAliasesAsync(@Nullable Duration timeout) { + logger.debug("List all aliases"); + ListenableFuture future = getCollections(timeout).listAliases(ListAliasesRequest.getDefaultInstance()); + addLogFailureCallback(future, "List aliases"); + return Futures.transform(future, ListAliasesResponse::getAliasesList, MoreExecutors.directExecutor()); + } + + //endregion + + //region Point Management + + /** + * Perform insert and updates on points. If a point with a given ID already exists, it will be overwritten. + * + * @param collectionName The name of the collection. + * @param points The points to be upserted + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture upsertAsync( + String collectionName, + List points) { + return upsertAsync(collectionName, points, null); + } + + /** + * Perform insert and updates on points. If a point with a given ID already exists, it will be overwritten. + * The call waits for the changes to be applied. + * + * @param collectionName The name of the collection. + * @param points The points to be upserted + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture upsertAsync( + String collectionName, + List points, + @Nullable Duration timeout) { + return upsertAsync( + UpsertPoints.newBuilder() + .setCollectionName(collectionName) + .addAllPoints(points) + .setWait(true) + .build(), + timeout); + } + + /** + * Perform insert and updates on points. If a point with a given ID already exists, it will be overwritten. + * + * @param request The upsert points request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture upsertAsync(UpsertPoints request) { + return upsertAsync(request, null); + } + + /** + * Perform insert and updates on points. If a point with a given ID already exists, it will be overwritten. + * + * @param request The upsert points request + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture upsertAsync( + UpsertPoints request, + @Nullable Duration timeout) { + String collectionName = request.getCollectionName(); + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Upsert {} points into '{}'", request.getPointsList().size(), collectionName); + ListenableFuture future = getPoints(timeout).upsert(request); + addLogFailureCallback(future, "Upsert"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + /** + * Deletes points. + * The call waits for the changes to be applied. + * + * @param collectionName The name of the collection. + * @param ids The ids of points to delete. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync( + String collectionName, + List ids) { + return deleteAsync(collectionName, ids, null); + } + + /** + * Deletes points. + * The call waits for the changes to be applied. + * + * @param collectionName The name of the collection. + * @param ids The ids of points to delete. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync( + String collectionName, + List ids, + @Nullable Duration timeout) { + return deleteAsync(DeletePoints.newBuilder() + .setCollectionName(collectionName) + .setPoints(PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()).build()) + .setWait(true) + .build(), + timeout); + } + + /** + * Deletes points. + * The call waits for the changes to be applied. + * + * @param collectionName The name of the collection. + * @param filter A filter selecting the points to be deleted. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync( + String collectionName, + Filter filter) { + return deleteAsync(collectionName, filter, null); + } + + /** + * Deletes points. + * + * @param collectionName The name of the collection. + * @param filter A filter selecting the points to be deleted. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync( + String collectionName, + Filter filter, + @Nullable Duration timeout) { + return deleteAsync(DeletePoints.newBuilder() + .setCollectionName(collectionName) + .setPoints(PointsSelector.newBuilder().setFilter(filter).build()) + .setWait(true) + .build(), + timeout); + } + + /** + * Deletes points. + * + * @param request The delete points request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync(DeletePoints request) { + return deleteAsync(request, null); + } + + /** + * Deletes points. + * + * @param request The delete points request + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteAsync( + DeletePoints request, + @Nullable Duration timeout) { + String collectionName = request.getCollectionName(); + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Delete from '{}'", collectionName); + ListenableFuture future = getPoints(timeout).delete(request); + addLogFailureCallback(future, "Delete"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + /** + * Retrieves points. Includes all payload, excludes vectors. + * + * @param collectionName The name of the collection. + * @param id The id of a point to retrieve + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + PointId id, + @Nullable ReadConsistency readConsistency + ) { + return retrieveAsync( + collectionName, + id, + true, + false, + readConsistency + ); + } + + /** + * Retrieves points. + * + * @param collectionName The name of the collection. + * @param id The id of a point to retrieve + * @param withPayload Whether to include the payload or not. + * @param withVectors Whether to include the vectors or not. + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + PointId id, + boolean withPayload, + boolean withVectors, + @Nullable ReadConsistency readConsistency + ) { + return retrieveAsync( + collectionName, + ImmutableList.of(id), + WithPayloadSelectorFactory.enable(withPayload), + WithVectorsSelectorFactory.enable(withVectors), + readConsistency + ); + } + + /** + * Retrieves points. Includes all payload, excludes vectors. + * + * @param collectionName The name of the collection. + * @param ids The list of ids of points to retrieve + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + List ids, + @Nullable ReadConsistency readConsistency + ) { + return retrieveAsync( + collectionName, + ids, + true, + false, + readConsistency + ); + } + + /** + * Retrieves points. + * + * @param collectionName The name of the collection. + * @param ids The list of ids of points to retrieve + * @param withPayload Whether to include the payload or not. + * @param withVectors Whether to include the vectors or not. + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + List ids, + boolean withPayload, + boolean withVectors, + @Nullable ReadConsistency readConsistency + ) { + return retrieveAsync( + collectionName, + ids, + WithPayloadSelectorFactory.enable(withPayload), + WithVectorsSelectorFactory.enable(withVectors), + readConsistency + ); + } + + /** + * Retrieves points. + * + * @param collectionName The name of the collection. + * @param ids The list of ids of points to retrieve + * @param payloadSelector Options for specifying which payload to include or not. + * @param vectorsSelector Options for specifying which vectors to include into response. + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + List ids, + WithPayloadSelector payloadSelector, + WithVectorsSelector vectorsSelector, + @Nullable ReadConsistency readConsistency + ) { + return retrieveAsync(collectionName, ids, payloadSelector, vectorsSelector, readConsistency, null); + } + + /** + * Retrieves points. + * + * @param collectionName The name of the collection. + * @param ids The list of ids of points to retrieve + * @param payloadSelector Options for specifying which payload to include or not. + * @param vectorsSelector Options for specifying which vectors to include into response. + * @param readConsistency Options for specifying read consistency guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> retrieveAsync( + String collectionName, + List ids, + WithPayloadSelector payloadSelector, + WithVectorsSelector vectorsSelector, + @Nullable ReadConsistency readConsistency, + @Nullable Duration timeout + ) { + logger.debug("Retrieve points from '{}'", collectionName); + GetPoints.Builder requestBuilder = GetPoints.newBuilder() + .setCollectionName(collectionName) + .addAllIds(ids) + .setWithPayload(payloadSelector) + .setWithVectors(vectorsSelector); + + if (readConsistency != null) { + requestBuilder.setReadConsistency(readConsistency); + } + + ListenableFuture future = getPoints(timeout).get(requestBuilder.build()); + addLogFailureCallback(future, "Retrieve"); + return Futures.transform(future, GetResponse::getResultList, MoreExecutors.directExecutor()); + } + + //region Update Vectors + + /** + * Update named vectors for point. + * + * @param collectionName The name of the collection. + * @param points The list of points and vectors to update. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateVectorsAsync( + String collectionName, + List points + ) { + return updateVectorsAsync(collectionName, points, null, null, null); + } + + /** + * Update named vectors for point. + * + * @param collectionName The name of the collection. + * @param points The list of points and vectors to update. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateVectorsAsync( + String collectionName, + List points, + @Nullable Duration timeout + ) { + return updateVectorsAsync(collectionName, points, null, null, timeout); + } + + /** + * Update named vectors for point. + * + * @param collectionName The name of the collection. + * @param points The list of points and vectors to update. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture updateVectorsAsync( + String collectionName, + List points, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + logger.debug("Update vectors in '{}'", collectionName); + UpdatePointVectors.Builder requestBuilder = UpdatePointVectors.newBuilder() + .setCollectionName(collectionName) + .addAllPoints(points) + .setWait(wait == null || wait); + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + ListenableFuture future = getPoints(timeout).updateVectors(requestBuilder.build()); + addLogFailureCallback(future, "Update vectors"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + //region Delete Vectors + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param filter A filter selecting the points to be deleted. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + Filter filter + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder().setFilter(filter).build(), + null, + null, + null + ); + } + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param filter A filter selecting the points to be deleted. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + Filter filter, + @Nullable Duration timeout + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder().setFilter(filter).build(), + null, + null, + timeout + ); + } + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param filter A filter selecting the points to be deleted. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + Filter filter, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder().setFilter(filter).build(), + wait, + ordering, + timeout + ); + } + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param ids The list of ids to delete. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + List ids + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder() + .setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()) + .build(), + null, + null, + null + ); + } + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param ids The list of ids to delete. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + List ids, + @Nullable Duration timeout + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder() + .setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()) + .build(), + null, + null, + timeout + ); + } + + /** + * Delete named vectors for points. + * + * @param collectionName The name of the collection. + * @param vectors The list of vector names to delete. + * @param ids The list of ids to delete. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + List ids, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deleteVectorsAsync( + collectionName, + vectors, + PointsSelector.newBuilder() + .setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()) + .build(), + wait, + ordering, + timeout + ); + } + + private ListenableFuture deleteVectorsAsync( + String collectionName, + List vectors, + PointsSelector pointsSelector, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + logger.debug("Delete vectors in '{}'", collectionName); + DeletePointVectors.Builder requestBuilder = DeletePointVectors.newBuilder() + .setCollectionName(collectionName) + .setVectors(VectorsSelector.newBuilder() + .addAllNames(vectors) + .build()) + .setPointsSelector(pointsSelector) + .setWait(wait == null || wait); + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + ListenableFuture future = getPoints(timeout).deleteVectors(requestBuilder.build()); + addLogFailureCallback(future, "Delete vectors"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + //endregion + + //region Set Payload + + /** + * Sets the payload for all points in the collection. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture setPayloadAsync( + String collectionName, + Map payload, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return setPayloadAsync( + collectionName, + payload, + (PointsSelector) null, + wait, + ordering, + timeout + ); + } + + /** + * Sets the payload for the given id. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param id The id for which to set the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture setPayloadAsync( + String collectionName, + Map payload, + PointId id, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return setPayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Sets the payload for the given ids. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param ids The ids for which to set the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture setPayloadAsync( + String collectionName, + Map payload, + List ids, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return setPayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Sets the payload for the given ids. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param filter A filter selecting the points to be set. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture setPayloadAsync( + String collectionName, + Map payload, + Filter filter, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return setPayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setFilter(filter).build(), + wait, + ordering, + timeout + ); + } + + private ListenableFuture setPayloadAsync( + String collectionName, + Map payload, + @Nullable PointsSelector pointsSelector, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + SetPayloadPoints.Builder requestBuilder = SetPayloadPoints.newBuilder() + .setCollectionName(collectionName) + .setWait(wait == null || wait) + .putAllPayload(payload); + + if (pointsSelector != null) { + requestBuilder.setPointsSelector(pointsSelector); + } + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Set payload in '{}'", collectionName); + ListenableFuture future = getPoints(timeout).setPayload(requestBuilder.build()); + addLogFailureCallback(future, "Set payload"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + //region Overwrite payload + + /** + * Overwrites the payload for all points in the collection. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture overwritePayloadAsync( + String collectionName, + Map payload, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return overwritePayloadAsync( + collectionName, + payload, + (PointsSelector) null, + wait, + ordering, + timeout + ); + } + + /** + * Overwrites the payload for the given id. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param id The id for which to overwrite the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture overwritePayloadAsync( + String collectionName, + Map payload, + PointId id, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return overwritePayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Overwrites the payload for the given ids. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param ids The ids for which to overwrite the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture overwritePayloadAsync( + String collectionName, + Map payload, + List ids, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return overwritePayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Overwrites the payload for the given ids. + * + * @param collectionName The name of the collection. + * @param payload New payload values + * @param filter A filter selecting the points for which to overwrite the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture overwritePayloadAsync( + String collectionName, + Map payload, + Filter filter, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return overwritePayloadAsync( + collectionName, + payload, + PointsSelector.newBuilder().setFilter(filter).build(), + wait, + ordering, + timeout + ); + } + + private ListenableFuture overwritePayloadAsync( + String collectionName, + Map payload, + @Nullable PointsSelector pointsSelector, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + SetPayloadPoints.Builder requestBuilder = SetPayloadPoints.newBuilder() + .setCollectionName(collectionName) + .setWait(wait == null || wait) + .putAllPayload(payload); + + if (pointsSelector != null) { + requestBuilder.setPointsSelector(pointsSelector); + } + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Overwrite payload in '{}'", collectionName); + ListenableFuture future = getPoints(timeout).overwritePayload(requestBuilder.build()); + addLogFailureCallback(future, "Overwrite payload"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + //region Delete Payload + + /** + * Delete specified key payload for all points. + * + * @param collectionName The name of the collection. + * @param keys List of keys to delete. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deletePayloadAsync( + String collectionName, + List keys, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deletePayloadAsync( + collectionName, + keys, + (PointsSelector) null, + wait, + ordering, + timeout + ); + } + + /** + * Delete specified key payload for the given id. + * + * @param collectionName The name of the collection. + * @param keys List of keys to delete. + * @param id The id for which to delete the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deletePayloadAsync( + String collectionName, + List keys, + PointId id, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deletePayloadAsync( + collectionName, + keys, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Delete specified key payload for the given ids. + * + * @param collectionName The name of the collection. + * @param keys List of keys to delete. + * @param ids The ids for which to delete the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deletePayloadAsync( + String collectionName, + List keys, + List ids, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deletePayloadAsync( + collectionName, + keys, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Delete specified key payload for the given ids. + * + * @param collectionName The name of the collection. + * @param keys List of keys to delete. + * @param filter A filter selecting the points to for which to delete the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deletePayloadAsync( + String collectionName, + List keys, + Filter filter, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return deletePayloadAsync( + collectionName, + keys, + PointsSelector.newBuilder().setFilter(filter).build(), + wait, + ordering, + timeout + ); + } + + private ListenableFuture deletePayloadAsync( + String collectionName, + List keys, + @Nullable PointsSelector pointsSelector, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + DeletePayloadPoints.Builder requestBuilder = DeletePayloadPoints.newBuilder() + .setCollectionName(collectionName) + .setWait(wait == null || wait) + .addAllKeys(keys); + + if (pointsSelector != null) { + requestBuilder.setPointsSelector(pointsSelector); + } + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Delete payload in '{}'", collectionName); + ListenableFuture future = getPoints(timeout).deletePayload(requestBuilder.build()); + addLogFailureCallback(future, "Delete payload"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + //region Clear Payload + + /** + * Remove all payload for all points. + * + * @param collectionName The name of the collection. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture clearPayloadAsync( + String collectionName, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return clearPayloadAsync( + collectionName, + (PointsSelector) null, + wait, + ordering, + timeout + ); + } + + /** + * Removes all payload for the given id. + * + * @param collectionName The name of the collection. + * @param id The id for which to remove the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture clearPayloadAsync( + String collectionName, + PointId id, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return clearPayloadAsync( + collectionName, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Removes all payload for the given ids. + * + * @param collectionName The name of the collection. + * @param ids The ids for which to remove the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture clearPayloadAsync( + String collectionName, + List ids, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return clearPayloadAsync( + collectionName, + PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()).build(), + wait, + ordering, + timeout + ); + } + + /** + * Removes all payload for the given ids. + * + * @param collectionName The name of the collection. + * @param filter A filter selecting the points for which to remove the payload. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture clearPayloadAsync( + String collectionName, + Filter filter, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + return clearPayloadAsync( + collectionName, + PointsSelector.newBuilder().setFilter(filter).build(), + wait, + ordering, + timeout + ); + } + + private ListenableFuture clearPayloadAsync( + String collectionName, + @Nullable PointsSelector pointsSelector, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + ClearPayloadPoints.Builder requestBuilder = ClearPayloadPoints.newBuilder() + .setCollectionName(collectionName) + .setWait(wait == null || wait); + + if (pointsSelector != null) { + requestBuilder.setPoints(pointsSelector); + } + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Clear payload in '{}'", collectionName); + ListenableFuture future = getPoints(timeout).clearPayload(requestBuilder.build()); + addLogFailureCallback(future, "Clear payload"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + //endregion + + /** + * Creates a payload field index in a collection. + * + * @param collectionName The name of the collection. + * @param field The field name to index. + * @param schemaType The schema type of the field. + * @param indexParams Payload index parameters. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createPayloadIndexAsync( + String collectionName, + String field, + PayloadSchemaType schemaType, + @Nullable PayloadIndexParams indexParams, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + CreateFieldIndexCollection.Builder requestBuilder = CreateFieldIndexCollection.newBuilder() + .setCollectionName(collectionName) + .setFieldName(field) + .setWait(wait == null || wait); + + switch (schemaType) { + case Keyword: + requestBuilder.setFieldType(FieldType.FieldTypeKeyword); + break; + case Integer: + requestBuilder.setFieldType(FieldType.FieldTypeInteger); + break; + case Float: + requestBuilder.setFieldType(FieldType.FieldTypeFloat); + break; + case Geo: + requestBuilder.setFieldType(FieldType.FieldTypeGeo); + break; + case Text: + requestBuilder.setFieldType(FieldType.FieldTypeText); + break; + case Bool: + requestBuilder.setFieldType(FieldType.FieldTypeBool); + break; + default: + throw new IllegalArgumentException("Invalid schemaType: '" + schemaType + "'"); + } + + if (indexParams != null) { + requestBuilder.setFieldIndexParams(indexParams); + } + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Create payload field index for '{}' in '{}'", field, collectionName); + ListenableFuture future = getPoints(timeout).createFieldIndex(requestBuilder.build()); + addLogFailureCallback(future, "Create payload field index"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + /** + * Deletes a payload field index in a collection. + * + * @param collectionName The name of the collection. + * @param field The field name to index. + * @param wait Whether to wait until the changes have been applied. Defaults to true. + * @param ordering Write ordering guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deletePayloadIndexAsync( + String collectionName, + String field, + @Nullable Boolean wait, + @Nullable WriteOrderingType ordering, + @Nullable Duration timeout + ) { + DeleteFieldIndexCollection.Builder requestBuilder = DeleteFieldIndexCollection.newBuilder() + .setCollectionName(collectionName) + .setFieldName(field) + .setWait(wait == null || wait); + + if (ordering != null) { + requestBuilder.setOrdering(WriteOrdering.newBuilder().setType(ordering).build()); + } + + logger.debug("Delete payload field index for '{}' in '{}'", field, collectionName); + ListenableFuture future = getPoints(timeout).deleteFieldIndex(requestBuilder.build()); + addLogFailureCallback(future, "Delete payload field index"); + return Futures.transform(future, PointsOperationResponse::getResult, MoreExecutors.directExecutor()); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions. + * + * @param request the search request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchAsync(SearchPoints request) { + return searchAsync(request, null); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions. + * + * @param request the search request + * @param timeout the timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchAsync(SearchPoints request, @Nullable Duration timeout) { + Preconditions.checkArgument( + !request.getCollectionName().isEmpty(), + "Collection name must not be empty"); + Preconditions.checkArgument( + !request.getVectorList().isEmpty(), + "Vector must not be empty"); + + logger.debug("Search on '{}'", request.getCollectionName()); + ListenableFuture future = getPoints(timeout).search(request); + addLogFailureCallback(future, "Search"); + return Futures.transform(future, SearchResponse::getResultList, MoreExecutors.directExecutor()); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions. + * + * @param collectionName The name of the collection + * @param searches The searches to be performed in the batch. + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchBatchAsync( + String collectionName, + List searches, + @Nullable ReadConsistency readConsistency + ) { + return searchBatchAsync(collectionName, searches, readConsistency, null); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions. + * + * @param collectionName The name of the collection + * @param searches The searches to be performed in the batch. + * @param readConsistency Options for specifying read consistency guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchBatchAsync( + String collectionName, + List searches, + @Nullable ReadConsistency readConsistency, + @Nullable Duration timeout + ) { + // TODO: Workaround for https://github.com/qdrant/qdrant/issues/2880 + searches = Lists.transform( + searches, + searchPoints -> searchPoints.toBuilder().setCollectionName(collectionName).build()); + + SearchBatchPoints.Builder requestBuilder = SearchBatchPoints.newBuilder() + .setCollectionName(collectionName) + .addAllSearchPoints(searches); + + if (readConsistency != null) { + requestBuilder.setReadConsistency(readConsistency); + } + + logger.debug("Search batch on '{}'", collectionName); + ListenableFuture future = getPoints(timeout).searchBatch(requestBuilder.build()); + addLogFailureCallback(future, "Search batch"); + return Futures.transform(future, SearchBatchResponse::getResultList, MoreExecutors.directExecutor()); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions, grouped by a given field. + * + * @param request The search group request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchGroupsAsync(SearchPointGroups request) { + return searchGroupsAsync(request, null); + } + + /** + * Retrieves closest points based on vector similarity and the given filtering conditions, grouped by a given field. + * + * @param request The search group request + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> searchGroupsAsync(SearchPointGroups request, @Nullable Duration timeout) { + Preconditions.checkArgument( + !request.getCollectionName().isEmpty(), + "Collection name must not be empty"); + logger.debug("Search groups on '{}'", request.getCollectionName()); + ListenableFuture future = getPoints(timeout).searchGroups(request); + addLogFailureCallback(future, "Search groups"); + return Futures.transform( + future, + response -> response.getResult().getGroupsList(), + MoreExecutors.directExecutor()); + } + + /** + * Iterates over all or filtered points. + * + * @param request The scroll request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture scrollAsync(ScrollPoints request) { + return scrollAsync(request, null); + } + + /** + * Iterates over all or filtered points. + * + * @param request The scroll request. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture scrollAsync(ScrollPoints request, @Nullable Duration timeout) { + Preconditions.checkArgument( + !request.getCollectionName().isEmpty(), + "Collection name must not be empty"); + logger.debug("Scroll on '{}'", request.getCollectionName()); + ListenableFuture future = getPoints(timeout).scroll(request); + addLogFailureCallback(future, "Scroll"); + return future; + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples. + * + * @param request The recommend request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendAsync(RecommendPoints request) { + return recommendAsync(request, null); + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples. + * + * @param request The recommend request. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendAsync(RecommendPoints request, @Nullable Duration timeout) { + Preconditions.checkArgument( + !request.getCollectionName().isEmpty(), + "Collection name must not be empty"); + logger.debug("Recommend on '{}'", request.getCollectionName()); + ListenableFuture future = getPoints(timeout).recommend(request); + addLogFailureCallback(future, "Recommend"); + return Futures.transform( + future, + RecommendResponse::getResultList, + MoreExecutors.directExecutor()); + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples. + * + * @param collectionName The name of the collection. + * @param recommendSearches The list of recommendation searches. + * @param readConsistency Options for specifying read consistency guarantees. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendBatchAsync( + String collectionName, + List recommendSearches, + @Nullable ReadConsistency readConsistency) { + return recommendBatchAsync(collectionName, recommendSearches, readConsistency, null); + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples. + * + * @param collectionName The name of the collection. + * @param recommendSearches The list of recommendation searches. + * @param readConsistency Options for specifying read consistency guarantees. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendBatchAsync( + String collectionName, + List recommendSearches, + @Nullable ReadConsistency readConsistency, + @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + + // TODO: Workaround for https://github.com/qdrant/qdrant/issues/2880 + recommendSearches = Lists.transform( + recommendSearches, + recommendPoints -> recommendPoints.toBuilder().setCollectionName(collectionName).build()); + + RecommendBatchPoints.Builder requestBuilder = RecommendBatchPoints.newBuilder() + .setCollectionName(collectionName) + .addAllRecommendPoints(recommendSearches); + + if (readConsistency != null) { + requestBuilder.setReadConsistency(readConsistency); + } + + logger.debug("Recommend batch on '{}'", collectionName); + ListenableFuture future = getPoints(timeout).recommendBatch(requestBuilder.build()); + addLogFailureCallback(future, "Recommend batch"); + return Futures.transform( + future, + RecommendBatchResponse::getResultList, + MoreExecutors.directExecutor()); + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples, grouped by a given field + * + * @param request The recommend groups request + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendGroupsAsync(RecommendPointGroups request) { + return recommendGroupsAsync(request, null); + } + + /** + * Look for the points which are closer to stored positive examples and at the same time further to negative + * examples, grouped by a given field + * + * @param request The recommend groups request + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> recommendGroupsAsync(RecommendPointGroups request, @Nullable Duration timeout) { + String collectionName = request.getCollectionName(); + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Recommend groups on '{}'", collectionName); + ListenableFuture future = getPoints(timeout).recommendGroups(request); + addLogFailureCallback(future, "Recommend groups"); + return Futures.transform( + future, + response -> response.getResult().getGroupsList(), + MoreExecutors.directExecutor()); + } + + /** + * Count the points in a collection. The count is exact + * + * @param collectionName The name of the collection. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture countAsync(String collectionName) { + return countAsync(collectionName, null, null, null); + } + + /** + * Count the points in a collection. The count is exact + * + * @param collectionName The name of the collection. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture countAsync(String collectionName, @Nullable Duration timeout) { + return countAsync(collectionName, null, null, timeout); + } + + /** + * Count the points in a collection with the given filtering conditions. + * + * @param collectionName The name of the collection. + * @param filter Filter conditions - return only those points that satisfy the specified conditions. + * @param exact If true, returns the exact count, + * if false, returns an approximate count. Defaults to true. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture countAsync( + String collectionName, + @Nullable Filter filter, + @Nullable Boolean exact) { + return countAsync(collectionName, filter, exact, null); + } + + /** + * Count the points in a collection with the given filtering conditions. + * + * @param collectionName The name of the collection. + * @param filter Filter conditions - return only those points that satisfy the specified conditions. + * @param exact If true, returns the exact count, + * if false, returns an approximate count. Defaults to true. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture countAsync( + String collectionName, + @Nullable Filter filter, + @Nullable Boolean exact, + @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + CountPoints.Builder requestBuilder = CountPoints.newBuilder() + .setCollectionName(collectionName) + .setExact(exact == null || exact); + + if (filter != null) { + requestBuilder.setFilter(filter); + } + + logger.debug("Count on '{}'", collectionName); + ListenableFuture future = getPoints(timeout).count(requestBuilder.build()); + addLogFailureCallback(future, "Count"); + return Futures.transform(future, response -> response.getResult().getCount(), MoreExecutors.directExecutor()); + } + + //region Snapshot Management + + /** + * Create snapshot for a given collection. + * + * @param collectionName The name of the collection. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createSnapshotAsync(String collectionName) { + return createSnapshotAsync(collectionName, null); + } + + /** + * Create snapshot for a given collection. + * + * @param collectionName The name of the collection. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createSnapshotAsync(String collectionName, @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("Create snapshot of '{}'", collectionName); + ListenableFuture future = getSnapshots(timeout).create( + CreateSnapshotRequest.newBuilder() + .setCollectionName(collectionName) + .build()); + addLogFailureCallback(future, "Create snapshot"); + return Futures.transform(future, CreateSnapshotResponse::getSnapshotDescription, MoreExecutors.directExecutor()); + } + + /** + * Get list of snapshots for a collection. + * + * @param collectionName The name of the collection. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listSnapshotAsync(String collectionName) { + return listSnapshotAsync(collectionName, null); + } + + /** + * Get list of snapshots for a collection. + * + * @param collectionName The name of the collection. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listSnapshotAsync(String collectionName, @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + logger.debug("List snapshots of '{}'", collectionName); + ListenableFuture future = getSnapshots(timeout).list(ListSnapshotsRequest.newBuilder() + .setCollectionName(collectionName) + .build()); + addLogFailureCallback(future, "List snapshots"); + return Futures.transform(future, ListSnapshotsResponse::getSnapshotDescriptionsList, MoreExecutors.directExecutor()); + } + + /** + * Delete snapshot for a given collection. + * + * @param collectionName The name of the collection. + * @param snapshotName The name of the snapshot. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteSnapshotAsync(String collectionName, String snapshotName) { + return deleteSnapshotAsync(collectionName, snapshotName, null); + } + + /** + * Delete snapshot for a given collection. + * + * @param collectionName The name of the collection. + * @param snapshotName The name of the snapshot. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteSnapshotAsync(String collectionName, String snapshotName, @Nullable Duration timeout) { + Preconditions.checkArgument(!collectionName.isEmpty(), "Collection name must not be empty"); + Preconditions.checkArgument(!snapshotName.isEmpty(), "Snapshot name must not be empty"); + logger.debug("Delete snapshot '{}' of '{}'", snapshotName, collectionName); + ListenableFuture future = getSnapshots(timeout).delete(DeleteSnapshotRequest.newBuilder() + .setCollectionName(collectionName) + .setSnapshotName(snapshotName) + .build()); + addLogFailureCallback(future, "Delete snapshot"); + return future; + } + + /** + * Create snapshot for a whole storage. + * + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createFullSnapshotAsync() { + return createFullSnapshotAsync(null); + } + + /** + * Create snapshot for a whole storage. + * + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture createFullSnapshotAsync(@Nullable Duration timeout) { + logger.debug("Create full snapshot for a whole storage"); + ListenableFuture future = + getSnapshots(timeout).createFull(CreateFullSnapshotRequest.getDefaultInstance()); + addLogFailureCallback(future, "Create full snapshot"); + return Futures.transform(future, CreateSnapshotResponse::getSnapshotDescription, MoreExecutors.directExecutor()); + } + + /** + * Get list of snapshots for a whole storage. + * + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listFullSnapshotAsync() { + return listFullSnapshotAsync(null); + } + + /** + * Get list of snapshots for a whole storage. + * + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture> listFullSnapshotAsync(@Nullable Duration timeout) { + logger.debug("List full snapshots for a whole storage"); + ListenableFuture future = + getSnapshots(timeout).listFull(ListFullSnapshotsRequest.getDefaultInstance()); + addLogFailureCallback(future, "List full snapshots"); + return Futures.transform(future, ListSnapshotsResponse::getSnapshotDescriptionsList, MoreExecutors.directExecutor()); + } + + /** + * Delete snapshot for a whole storage. + * + * @param snapshotName The name of the snapshot. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteFullSnapshotAsync(String snapshotName) { + return deleteFullSnapshotAsync(snapshotName, null); + } + + /** + * Delete snapshot for a whole storage. + * + * @param snapshotName The name of the snapshot. + * @param timeout The timeout for the call. + * @return a new instance of {@link ListenableFuture} + */ + public ListenableFuture deleteFullSnapshotAsync(String snapshotName, @Nullable Duration timeout) { + Preconditions.checkArgument(!snapshotName.isEmpty(), "Snapshot name must not be empty"); + logger.debug("Delete full snapshot '{}'", snapshotName); + ListenableFuture future = getSnapshots(timeout).deleteFull(DeleteFullSnapshotRequest.newBuilder() + .setSnapshotName(snapshotName) + .build()); + addLogFailureCallback(future, "Delete full snapshot"); + return future; + } + + //endregion + + @Override + public void close() { + grpcClient.close(); + } + + private void addLogFailureCallback(ListenableFuture future, String message) { + Futures.addCallback(future, new FutureCallback() { + @Override + public void onSuccess(V result) { + } + + @Override + public void onFailure(Throwable t) { + logger.error(message + " operation failed", t); + } + }, MoreExecutors.directExecutor()); + } + + private CollectionsGrpc.CollectionsFutureStub getCollections(@Nullable Duration timeout) { + return timeout != null + ? this.grpcClient.collections().withDeadlineAfter(timeout.toMillis(), TimeUnit.MILLISECONDS) + : this.grpcClient.collections(); + } + + private PointsGrpc.PointsFutureStub getPoints(@Nullable Duration timeout) { + return timeout != null + ? this.grpcClient.points().withDeadlineAfter(timeout.toMillis(), TimeUnit.MILLISECONDS) + : this.grpcClient.points(); + } + + private SnapshotsGrpc.SnapshotsFutureStub getSnapshots(@Nullable Duration timeout) { + return timeout != null + ? this.grpcClient.snapshots().withDeadlineAfter(timeout.toMillis(), TimeUnit.MILLISECONDS) + : this.grpcClient.snapshots(); + } } diff --git a/src/main/java/io/qdrant/client/QdrantException.java b/src/main/java/io/qdrant/client/QdrantException.java new file mode 100644 index 00000000..740b0bf5 --- /dev/null +++ b/src/main/java/io/qdrant/client/QdrantException.java @@ -0,0 +1,14 @@ +package io.qdrant.client; + +/** + * An exception when interacting with qdrant + */ +public class QdrantException extends RuntimeException { + /** + * Instantiates a new instance of {@link QdrantException} + * @param message The exception message + */ + public QdrantException(String message) { + super(message); + } +} diff --git a/src/main/java/io/qdrant/client/QdrantGrpcClient.java b/src/main/java/io/qdrant/client/QdrantGrpcClient.java new file mode 100644 index 00000000..0015ddb6 --- /dev/null +++ b/src/main/java/io/qdrant/client/QdrantGrpcClient.java @@ -0,0 +1,219 @@ +package io.qdrant.client; + +import io.qdrant.client.grpc.CollectionsGrpc; +import io.qdrant.client.grpc.PointsGrpc; +import io.qdrant.client.grpc.QdrantGrpc; +import io.qdrant.client.grpc.QdrantGrpc.QdrantFutureStub; +import io.qdrant.client.grpc.SnapshotsGrpc; +import io.grpc.CallCredentials; +import io.grpc.Deadline; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; +import java.time.Duration; +import java.util.concurrent.TimeUnit; + +import static io.qdrant.client.grpc.CollectionsGrpc.CollectionsFutureStub; +import static io.qdrant.client.grpc.PointsGrpc.PointsFutureStub; +import static io.qdrant.client.grpc.SnapshotsGrpc.SnapshotsFutureStub; + +/** + * Low-level gRPC client for qdrant vector database. + */ +public class QdrantGrpcClient implements AutoCloseable { + private static final Logger logger = LoggerFactory.getLogger(QdrantGrpcClient.class); + @Nullable + private final CallCredentials callCredentials; + private final ManagedChannel channel; + private final boolean shutdownChannelOnClose; + @Nullable + private final Duration timeout; + + QdrantGrpcClient( + ManagedChannel channel, + boolean shutdownChannelOnClose, + @Nullable CallCredentials callCredentials, + @Nullable Duration timeout) { + this.callCredentials = callCredentials; + this.channel = channel; + this.shutdownChannelOnClose = shutdownChannelOnClose; + this.timeout = timeout; + } + + /** + * Creates a new builder to build a client. + * @param channel The channel for communication. This channel is not shutdown by the client and must be managed + * by the caller. + * @return a new instance of {@link Builder} + */ + public static Builder newBuilder(ManagedChannel channel) { + return new Builder(channel, false); + } + + /** + * Creates a new builder to build a client. + * @param channel The channel for communication. + * @param shutdownChannelOnClose Whether the channel is shutdown on client close. + * @return a new instance of {@link Builder} + */ + public static Builder newBuilder(ManagedChannel channel, boolean shutdownChannelOnClose) { + return new Builder(channel, shutdownChannelOnClose); + } + + /** + * Creates a new builder to build a client. + * @param host The host to connect to. The default gRPC port 6334 is used. + * @return a new instance of {@link Builder} + */ + public static Builder newBuilder(String host) { + return new Builder(host, 6334, true); + } + + /** + * Creates a new builder to build a client. The client uses Transport Layer Security by default. + * @param host The host to connect to. + * @param port The port to connect to. + * @return a new instance of {@link Builder} + */ + public static Builder newBuilder(String host, int port) { + return new Builder(host, port, true); + } + + /** + * Creates a new builder to build a client. + * @param host The host to connect to. + * @param port The port to connect to. + * @param useTransportLayerSecurity Whether the client uses Transport Layer Security (TLS) to secure communications. + * Running without TLS should only be used for testing purposes. + * @return a new instance of {@link Builder} + */ + public static Builder newBuilder(String host, int port, boolean useTransportLayerSecurity) { + return new Builder(host, port, useTransportLayerSecurity); + } + + /** + * Gets the client for qdrant services + * @return a new instance of {@link QdrantFutureStub} + */ + public QdrantGrpc.QdrantFutureStub qdrant() { + return QdrantGrpc.newFutureStub(channel) + .withCallCredentials(callCredentials) + .withDeadline(timeout != null ? Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS) : null); + } + + /** + * Gets the client for points + * @return a new instance of {@link PointsFutureStub} + */ + public PointsFutureStub points() { + return PointsGrpc.newFutureStub(channel) + .withCallCredentials(callCredentials) + .withDeadline(timeout != null ? Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS) : null); + } + + /** + * Gets the client for collections + * @return a new instance of {@link CollectionsFutureStub} + */ + public CollectionsFutureStub collections() { + return CollectionsGrpc.newFutureStub(channel) + .withCallCredentials(callCredentials) + .withDeadline(timeout != null ? Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS) : null); + } + + /** + * Gets the client for snapshots + * @return a new instance of {@link SnapshotsFutureStub} + */ + public SnapshotsFutureStub snapshots() { + return SnapshotsGrpc.newFutureStub(channel) + .withCallCredentials(callCredentials) + .withDeadline(timeout != null ? Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS) : null); + } + + @Override + public void close() { + if (shutdownChannelOnClose && !channel.isShutdown() && !channel.isTerminated()) { + try { + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + logger.warn("exception thrown when shutting down channel", e); + } + } + } + + /** + * builder for {@link QdrantGrpcClient} + */ + public static class Builder { + private final ManagedChannel channel; + private final boolean shutdownChannelOnClose; + @Nullable + private CallCredentials callCredentials; + @Nullable + private Duration timeout; + + Builder(ManagedChannel channel, boolean shutdownChannelOnClose) { + this.channel = channel; + this.shutdownChannelOnClose = shutdownChannelOnClose; + } + + Builder(String host, int port, boolean useTransportLayerSecurity) { + this.channel = createChannel(host, port, useTransportLayerSecurity); + this.shutdownChannelOnClose = true; + } + + /** + * Sets the API key to use for authentication + * @param apiKey The API key to use. + * @return this + */ + public Builder withApiKey(String apiKey) { + this.callCredentials = new ApiKeyCredentials(apiKey); + return this; + } + + /** + * Sets a default timeout for all requests. + * @param timeout The timeout. + * @return this + */ + public Builder withTimeout(@Nullable Duration timeout) { + this.timeout = timeout; + return this; + } + + /** + * Sets the credential data that will be propagated to the server via request metadata for each RPC. + * @param callCredentials The call credentials to use. + * @return this + */ + public Builder withCallCredentials(@Nullable CallCredentials callCredentials) { + this.callCredentials = callCredentials; + return this; + } + + /** + * Builds a new instance of {@link QdrantGrpcClient} + * @return a new instance of {@link QdrantGrpcClient} + */ + public QdrantGrpcClient build() { + return new QdrantGrpcClient(channel, shutdownChannelOnClose, callCredentials, timeout); + } + + private static ManagedChannel createChannel(String host, int port, boolean useTransportLayerSecurity) { + ManagedChannelBuilder channelBuilder = ManagedChannelBuilder.forAddress(host, port); + + if (useTransportLayerSecurity) { + channelBuilder.useTransportSecurity(); + } else { + channelBuilder.usePlaintext(); + } + + return channelBuilder.build(); + } + } +} diff --git a/src/main/java/io/qdrant/client/TokenInterceptor.java b/src/main/java/io/qdrant/client/TokenInterceptor.java deleted file mode 100644 index f735ed42..00000000 --- a/src/main/java/io/qdrant/client/TokenInterceptor.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.qdrant.client; - -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; -import io.grpc.ForwardingClientCall.SimpleForwardingClientCall; -import io.grpc.Metadata; -import io.grpc.MethodDescriptor; - -/** Interceptor for adding an API key to the headers of gRPC requests. */ -final class TokenInterceptor implements ClientInterceptor { - private final String apiKey; - private final Metadata.Key API_KEY = - Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER); - - /** - * Constructs a new TokenInterceptor with the specified API key. - * - * @param apiKey the API key to be added to the headers - */ - TokenInterceptor(String apiKey) { - this.apiKey = apiKey; - } - - @Override - public ClientCall interceptCall( - MethodDescriptor method, CallOptions callOptions, Channel next) { - return new SimpleForwardingClientCall(next.newCall(method, callOptions)) { - @Override - public void start(Listener responseListener, Metadata headers) { - headers.put(API_KEY, apiKey); - super.start(responseListener, headers); - } - }; - } -} diff --git a/src/main/java/io/qdrant/client/ValueFactory.java b/src/main/java/io/qdrant/client/ValueFactory.java new file mode 100644 index 00000000..f2264cd2 --- /dev/null +++ b/src/main/java/io/qdrant/client/ValueFactory.java @@ -0,0 +1,70 @@ +package io.qdrant.client; + +import java.util.List; + +import static io.qdrant.client.grpc.JsonWithInt.ListValue; +import static io.qdrant.client.grpc.JsonWithInt.NullValue; +import static io.qdrant.client.grpc.JsonWithInt.Value; + +/** + * Convenience methods for constructing {@link Value} + */ +public final class ValueFactory { + private ValueFactory() { + } + + /** + * Creates a value from a {@link String} + * @param value The value + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value value(String value) { + return Value.newBuilder().setStringValue(value).build(); + } + + /** + * Creates a value from a {@link long} + * @param value The value + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value value(long value) { + return Value.newBuilder().setIntegerValue(value).build(); + } + + /** + * Creates a value from a {@link double} + * @param value The value + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value value(double value) { + return Value.newBuilder().setDoubleValue(value).build(); + } + + /** + * Creates a value from a {@link boolean} + * @param value The value + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value value(boolean value) { + return Value.newBuilder().setBoolValue(value).build(); + } + + /** + * Creates a null value + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value nullValue() { + return Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); + } + + /** + * Creates a value from a list of values + * @param values The list of values + * @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value} + */ + public static Value list(List values) { + return Value.newBuilder() + .setListValue(ListValue.newBuilder().addAllValues(values).build()) + .build(); + } +} diff --git a/src/main/java/io/qdrant/client/VectorsFactory.java b/src/main/java/io/qdrant/client/VectorsFactory.java new file mode 100644 index 00000000..0e2c3486 --- /dev/null +++ b/src/main/java/io/qdrant/client/VectorsFactory.java @@ -0,0 +1,60 @@ +package io.qdrant.client; + +import com.google.common.collect.Maps; +import com.google.common.primitives.Floats; + +import java.util.List; +import java.util.Map; + +import static io.qdrant.client.grpc.Points.NamedVectors; +import static io.qdrant.client.grpc.Points.Vector; +import static io.qdrant.client.grpc.Points.Vectors; + +/** + * Convenience methods for constructing {@link Vectors} + */ +public final class VectorsFactory { + private VectorsFactory() { + } + + /** + * Creates named vectors + * @param values A map of vector names to values + * @return a new instance of {@link Vectors} + */ + public static Vectors namedVectors(Map> values) { + return Vectors.newBuilder() + .setVectors(NamedVectors.newBuilder() + .putAllVectors(Maps.transformValues(values, v -> Vector.newBuilder() + .addAllData(v) + .build())) + ) + .build(); + } + + /** + * Creates a vector + * @param values A list of values + * @return a new instance of {@link Vectors} + */ + public static Vectors vector(List values) { + return Vectors.newBuilder() + .setVector(Vector.newBuilder() + .addAllData(values) + .build()) + .build(); + } + + /** + * Creates a vector + * @param values A list of values + * @return a new instance of {@link Vectors} + */ + public static Vectors vector(float... values) { + return Vectors.newBuilder() + .setVector(Vector.newBuilder() + .addAllData(Floats.asList(values)) + .build()) + .build(); + } +} diff --git a/src/main/java/io/qdrant/client/WithPayloadSelectorFactory.java b/src/main/java/io/qdrant/client/WithPayloadSelectorFactory.java new file mode 100644 index 00000000..02c61363 --- /dev/null +++ b/src/main/java/io/qdrant/client/WithPayloadSelectorFactory.java @@ -0,0 +1,46 @@ +package io.qdrant.client; + +import java.util.List; + +import static io.qdrant.client.grpc.Points.PayloadExcludeSelector; +import static io.qdrant.client.grpc.Points.PayloadIncludeSelector; +import static io.qdrant.client.grpc.Points.WithPayloadSelector; + +/** + * Convenience methods for constructing {@link WithPayloadSelector} + */ +public final class WithPayloadSelectorFactory { + private WithPayloadSelectorFactory() { + } + + /** + * Whether to include all payload in response. + * @param enable if true, to include all payload, if false, none. + * @return a new instance of {@link WithPayloadSelector} + */ + public static WithPayloadSelector enable(boolean enable) { + return WithPayloadSelector.newBuilder().setEnable(enable).build(); + } + + /** + * Which payload fields to include in response. + * @param fields the list of fields to include. + * @return a new instance of {@link WithPayloadSelector} + */ + public static WithPayloadSelector include(List fields) { + return WithPayloadSelector.newBuilder() + .setInclude(PayloadIncludeSelector.newBuilder().addAllFields(fields).build()) + .build(); + } + + /** + * Which payload fields to exclude in response. + * @param fields the list of fields to exclude. + * @return a new instance of {@link WithPayloadSelector} + */ + public static WithPayloadSelector exclude(List fields) { + return WithPayloadSelector.newBuilder() + .setExclude(PayloadExcludeSelector.newBuilder().addAllFields(fields).build()) + .build(); + } +} diff --git a/src/main/java/io/qdrant/client/WithVectorsSelectorFactory.java b/src/main/java/io/qdrant/client/WithVectorsSelectorFactory.java new file mode 100644 index 00000000..60cb69ad --- /dev/null +++ b/src/main/java/io/qdrant/client/WithVectorsSelectorFactory.java @@ -0,0 +1,35 @@ +package io.qdrant.client; + +import io.qdrant.client.grpc.Points; + +import java.util.List; + +import static io.qdrant.client.grpc.Points.WithVectorsSelector; + +/** + * Convenience methods for constructing {@link WithVectorsSelector} + */ +public final class WithVectorsSelectorFactory { + private WithVectorsSelectorFactory() { + } + + /** + * Whether to include vectors in response. + * @param enable if true, to include vectors, if false, none. + * @return a new instance of {@link WithVectorsSelector} + */ + public static WithVectorsSelector enable(boolean enable) { + return WithVectorsSelector.newBuilder().setEnable(enable).build(); + } + + /** + * List of named vectors to include in response. + * @param names The names of vectors. + * @return a new instance of {@link WithVectorsSelector} + */ + public static WithVectorsSelector include(List names) { + return WithVectorsSelector.newBuilder() + .setInclude(Points.VectorsSelector.newBuilder().addAllNames(names)) + .build(); + } +} diff --git a/src/main/java/io/qdrant/client/package-info.java b/src/main/java/io/qdrant/client/package-info.java new file mode 100644 index 00000000..05885bd9 --- /dev/null +++ b/src/main/java/io/qdrant/client/package-info.java @@ -0,0 +1,7 @@ +/** + * package + */ +@ParametersAreNonnullByDefault +package io.qdrant.client; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/io/qdrant/client/utils/FilterUtil.java b/src/main/java/io/qdrant/client/utils/FilterUtil.java deleted file mode 100644 index 8e452f3e..00000000 --- a/src/main/java/io/qdrant/client/utils/FilterUtil.java +++ /dev/null @@ -1,375 +0,0 @@ -package io.qdrant.client.utils; - -import io.qdrant.client.grpc.Points.Condition; -import io.qdrant.client.grpc.Points.FieldCondition; -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.GeoBoundingBox; -import io.qdrant.client.grpc.Points.GeoLineString; -import io.qdrant.client.grpc.Points.GeoPoint; -import io.qdrant.client.grpc.Points.GeoPolygon; -import io.qdrant.client.grpc.Points.GeoRadius; -import io.qdrant.client.grpc.Points.HasIdCondition; -import io.qdrant.client.grpc.Points.IsEmptyCondition; -import io.qdrant.client.grpc.Points.IsNullCondition; -import io.qdrant.client.grpc.Points.Match; -import io.qdrant.client.grpc.Points.NestedCondition; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.Range; -import io.qdrant.client.grpc.Points.RepeatedIntegers; -import io.qdrant.client.grpc.Points.RepeatedStrings; -import io.qdrant.client.grpc.Points.ValuesCount; -import java.util.Arrays; -import java.util.List; - -/** Utility class for creating filter conditions and filters. */ -public class FilterUtil { - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for text matching. - * - * @param key The key of the field. - * @param match The text match criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, Match match) { - FieldCondition fieldCondition = FieldCondition.newBuilder().setKey(key).setMatch(match).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for range matching. - * - * @param key The key of the field. - * @param range The range criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, Range range) { - FieldCondition fieldCondition = FieldCondition.newBuilder().setKey(key).setRange(range).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for geo bounding box matching. - * - * @param key The key of the field. - * @param geoBoundingBox The geo bounding box criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, GeoBoundingBox geoBoundingBox) { - FieldCondition fieldCondition = - FieldCondition.newBuilder().setKey(key).setGeoBoundingBox(geoBoundingBox).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for geo radius matching. - * - * @param key The key of the field. - * @param geoRadius The geo radius criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, GeoRadius geoRadius) { - FieldCondition fieldCondition = - FieldCondition.newBuilder().setKey(key).setGeoRadius(geoRadius).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for values count matching. - * - * @param key The key of the field. - * @param valuesCount The values count criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, ValuesCount valuesCount) { - FieldCondition fieldCondition = - FieldCondition.newBuilder().setKey(key).setValuesCount(valuesCount).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link FieldCondition} for geo polygon matching. - * - * @param key The key of the field. - * @param geoPolygon The geo polygon criteria. - * @return The created condition. - */ - public static Condition fieldCondition(String key, GeoPolygon geoPolygon) { - FieldCondition fieldCondition = - FieldCondition.newBuilder().setKey(key).setGeoPolygon(geoPolygon).build(); - - return Condition.newBuilder().setField(fieldCondition).build(); - } - - /** - * Creates a {@link Match} condition for string matching. If the text contains a space, it is - * considered a full-text match. Else it is considered a keyword match. - * - * @param text The text to match. - * @return The created match condition. - */ - public static Match match(String text) { - return text.contains(" ") - ? Match.newBuilder().setText(text).build() - : Match.newBuilder().setKeyword(text).build(); - } - - /** - * Creates a {@link Match} condition for integer matching. - * - * @param value The integer value to match. - * @return The created match condition. - */ - public static Match match(long value) { - return Match.newBuilder().setInteger(value).build(); - } - - /** - * Creates a {@link Match} condition for boolean matching. - * - * @param value The boolean value to match. - * @return The created match condition. - */ - public static Match match(boolean value) { - return Match.newBuilder().setBoolean(value).build(); - } - - /** - * Creates a {@link Match} condition with a list of keywords for matching. - * - * @param keywords The list of keywords to match. - * @return The created match condition. - */ - public static Match matchWithKeywords(List keywords) { - return Match.newBuilder() - .setKeywords(RepeatedStrings.newBuilder().addAllStrings(keywords).build()) - .build(); - } - - /** - * Creates a {@link Match} condition with a list of integers for matching. - * - * @param integers The list of integers to match. - * @return The created match condition. - */ - public static Match matchWithIntegers(List integers) { - return Match.newBuilder() - .setIntegers(RepeatedIntegers.newBuilder().addAllIntegers(integers).build()) - .build(); - } - - /** - * Creates a {@link GeoBoundingBox} based on the top-left and bottom-right {@link GeoPoint}s. - * - * @param topLeft The top-left point of the bounding box. - * @param bottomRight The bottom-right point of the bounding box. - * @return The created geo bounding box. - */ - public static GeoBoundingBox geoBoundingBox(GeoPoint topLeft, GeoPoint bottomRight) { - return GeoBoundingBox.newBuilder().setTopLeft(topLeft).setBottomRight(bottomRight).build(); - } - - /** - * Creates a {@link GeoRadius} based on the center {@link GeoPoint} and radius. - * - * @param center The center point of the radius. - * @param radius The radius value. - * @return The created geo radius. - */ - public static GeoRadius geoRadius(GeoPoint center, float radius) { - return GeoRadius.newBuilder().setCenter(center).setRadius(radius).build(); - } - - /** - * Creates a {@link GeoPolygon} based on the exterior {@link GeoLineString} and a list of interior - * {@link GeoLineString}s. - * - * @param exterior The exterior line string. - * @param interiors The list of interior line strings. - * @return The created geo polygon. - */ - public static GeoPolygon geoPolygon(GeoLineString exterior, List interiors) { - return GeoPolygon.newBuilder().setExterior(exterior).addAllInteriors(interiors).build(); - } - - /** - * Creates a {@link Range} for numeric range matching. - * - * @param lt The less than value. - * @param gt The greater than value. - * @param gte The greater than or equal to value. - * @param lte The less than or equal to value. - * @return The created range. - */ - public static Range range(double lt, double gt, double gte, double lte) { - return Range.newBuilder().setLt(lt).setGt(gt).setGte(gte).setLte(lte).build(); - } - - /** - * Creates a {@link ValuesCount} for values count matching. - * - * @param lt The less than value. - * @param gt The greater than value. - * @param gte The greater than or equal to value. - * @param lte The less than or equal to value. - * @return The created values count. - */ - public static ValuesCount valuesCount(long lt, long gt, long gte, long lte) { - return ValuesCount.newBuilder().setLt(lt).setGt(gt).setGte(gte).setLte(lte).build(); - } - - /** - * Creates a {@link Condition} with a {@link Filter} as a subcondition. - * - * @param filter The filter criteria. - * @return The created condition. - */ - public static Condition filterCondition(Filter filter) { - return Condition.newBuilder().setFilter(filter).build(); - } - - /** - * Creates a {@link Condition} with a {@link NestedCondition} based on a key and a nested filter. - * - * @param key The key of the nested condition. - * @param filter The nested filter criteria. - * @return The created condition. - */ - public static Condition nestedCondition(String key, Filter filter) { - validateNestedFilter(filter); - - NestedCondition nestedCondition = - NestedCondition.newBuilder().setKey(key).setFilter(filter).build(); - - return Condition.newBuilder().setNested(nestedCondition).build(); - } - - private static void validateNestedFilter(Filter filter) { - validateNoHasId(filter.getMustList()); - validateNoHasId(filter.getMustNotList()); - validateNoHasId(filter.getShouldList()); - } - - private static void validateNoHasId(List conditions) { - for (Condition condition : conditions) { - if (condition.hasHasId()) { - throw new IllegalArgumentException("Nested filter cannot have a HasIdCondition"); - } - } - } - - /** - * Creates a {@link Condition} with an {@link IsEmptyCondition} based on a key for empty condition - * matching. - * - * @param key The key of the field. - * @return The created condition. - */ - public static Condition isEmptyCondition(String key) { - IsEmptyCondition isEmptyCondition = IsEmptyCondition.newBuilder().setKey(key).build(); - - return Condition.newBuilder().setIsEmpty(isEmptyCondition).build(); - } - - /** - * Creates a {@link Condition} with an {@link IsNullCondition} based on a key for null condition - * matching. - * - * @param key The key of the field. - * @return The created condition. - */ - public static Condition isNullCondition(String key) { - IsNullCondition isNullCondition = IsNullCondition.newBuilder().setKey(key).build(); - - return Condition.newBuilder().setIsNull(isNullCondition).build(); - } - - /** - * Creates a {@link Condition} with a {@link HasIdCondition} based on a list of point IDs for ID - * condition matching. - * - * @param pointIds The list of point IDs. - * @return The created condition. - */ - public static Condition hasIdCondition(List pointIds) { - HasIdCondition hasIdCondition = HasIdCondition.newBuilder().addAllHasId(pointIds).build(); - - return Condition.newBuilder().setHasId(hasIdCondition).build(); - } - - /** - * Creates a {@link GeoPoint} based on latitude and longitude values. - * - * @param latitude The latitude value. - * @param longitude The longitude value. - * @return The created geo point. - */ - public static GeoPoint geoPoint(double latitude, double longitude) { - return GeoPoint.newBuilder().setLat(latitude).setLon(longitude).build(); - } - - /** - * Creates a {@link Filter} with "must" conditions. - * - * @param mustConditions The list of "must" conditions. - * @return The created filter. - */ - public static Filter must(Condition... mustConditions) { - return Filter.newBuilder().addAllMust(Arrays.asList(mustConditions)).build(); - } - - /** - * Creates a {@link Filter} with "must not" conditions. - * - * @param mustNotConditions The list of "must not" conditions. - * @return The created filter. - */ - public static Filter mustNot(Condition... mustNotConditions) { - return Filter.newBuilder().addAllMustNot(Arrays.asList(mustNotConditions)).build(); - } - - /** - * Creates a {@link Filter} with "should" conditions. - * - * @param shouldConditions The list of "should" conditions. - * @return The created filter. - */ - public static Filter should(Condition... shouldConditions) { - return Filter.newBuilder().addAllShould(Arrays.asList(shouldConditions)).build(); - } - - /** - * Creates a {@link Filter} with "must" conditions. - * - * @param mustConditions The list of "must" conditions. - * @return The created filter. - */ - public static Filter must(List mustConditions) { - return Filter.newBuilder().addAllMust(mustConditions).build(); - } - - /** - * Creates a {@link Filter} with "must not" conditions. - * - * @param mustNotConditions The list of "must not" conditions. - * @return The created filter. - */ - public static Filter mustNot(List mustNotConditions) { - return Filter.newBuilder().addAllMustNot(mustNotConditions).build(); - } - - /** - * Creates a {@link Filter} with "should" conditions. - * - * @param shouldConditions The list of "should" conditions. - * @return The created filter. - */ - public static Filter should(List shouldConditions) { - return Filter.newBuilder().addAllShould(shouldConditions).build(); - } -} diff --git a/src/main/java/io/qdrant/client/utils/PayloadUtil.java b/src/main/java/io/qdrant/client/utils/PayloadUtil.java deleted file mode 100644 index 01fa6938..00000000 --- a/src/main/java/io/qdrant/client/utils/PayloadUtil.java +++ /dev/null @@ -1,154 +0,0 @@ -package io.qdrant.client.utils; - -import io.qdrant.client.grpc.JsonWithInt.ListValue; -import io.qdrant.client.grpc.JsonWithInt.NullValue; -import io.qdrant.client.grpc.JsonWithInt.Struct; -import io.qdrant.client.grpc.JsonWithInt.Value; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** Utility class for working with Payloads. */ -public class PayloadUtil { - - /** - * Converts a map to a payload struct. - * - * @param inputMap The input map to convert. - * @return The converted payload struct. - */ - public static Struct toPayloadStruct(Map inputMap) { - Struct.Builder structBuilder = Struct.newBuilder(); - Map map = toPayload(inputMap); - structBuilder.putAllFields(map); - return structBuilder.build(); - } - - /** - * Converts a map to a payload map. - * - * @param inputMap The input map to convert. - * @return The converted payload map. - */ - public static Map toPayload(Map inputMap) { - Map map = new HashMap<>(); - for (Map.Entry entry : inputMap.entrySet()) { - String fieldName = entry.getKey(); - Object value = entry.getValue(); - - Value.Builder valueBuilder = Value.newBuilder(); - setValue(valueBuilder, value); - map.put(fieldName, valueBuilder.build()); - } - return map; - } - - /** - * Converts a payload struct to a Java Map. - * - * @param struct The payload struct to convert. - * @return The converted hash map. - */ - public static Map toMap(Struct struct) { - Map structMap = toMap(struct.getFieldsMap()); - return structMap; - } - - /** - * Converts a payload map to a Java Map. - * - * @param payload The payload map to convert. - * @return The converted hash map. - */ - public static Map toMap(Map payload) { - Map hashMap = new HashMap<>(); - for (Map.Entry entry : payload.entrySet()) { - String fieldName = entry.getKey(); - Value fieldValue = entry.getValue(); - - Object value = valueToObject(fieldValue); - hashMap.put(fieldName, value); - } - return hashMap; - } - - /** - * Sets the value of a Value.Builder based on the given object. - * - * @param valueBuilder The Value.Builder to set the value for. - * @param value The object value to set. - */ - static void setValue(Value.Builder valueBuilder, Object value) { - if (value == null) { - valueBuilder.setNullValue(NullValue.NULL_VALUE); - } else if (value instanceof String) { - valueBuilder.setStringValue((String) value); - } else if (value instanceof Integer) { - valueBuilder.setIntegerValue((Integer) value); - } else if (value instanceof Double) { - valueBuilder.setDoubleValue((Double) value); - } else if (value instanceof Boolean) { - valueBuilder.setBoolValue((Boolean) value); - } else if (value instanceof Map) { - valueBuilder.setStructValue(toPayloadStruct((Map) value)); - } else if (value instanceof List) { - valueBuilder.setListValue(listToListValue((List) value)); - } - } - - /** - * Converts a list to a ListValue.Builder. - * - * @param list The list to convert. - * @return The converted ListValue.Builder. - */ - static ListValue.Builder listToListValue(List list) { - ListValue.Builder listValueBuilder = ListValue.newBuilder(); - - for (Object element : list) { - Value.Builder elementBuilder = Value.newBuilder(); - setValue(elementBuilder, element); - listValueBuilder.addValues(elementBuilder.build()); - } - - return listValueBuilder; - } - - /** - * Converts a ListValue to an array of objects. - * - * @param listValue The ListValue to convert. - * @return The converted array of objects. - */ - static Object listValueToList(ListValue listValue) { - return listValue.getValuesList().stream().map(PayloadUtil::valueToObject).toArray(); - } - - /** - * Converts a Value to an object. - * - * @param value The Value to convert. - * @return The converted object. - */ - static Object valueToObject(Value value) { - if (value.hasStringValue()) { - return value.getStringValue(); - } else if (value.hasIntegerValue()) { - // int64 is converted to long - // We need to cast it to int - return (int) value.getIntegerValue(); - } else if (value.hasDoubleValue()) { - return value.getDoubleValue(); - } else if (value.hasBoolValue()) { - return value.getBoolValue(); - } else if (value.hasNullValue()) { - return null; - } else if (value.hasStructValue()) { - return toMap(value.getStructValue()); - } else if (value.hasListValue()) { - return listValueToList(value.getListValue()); - } - - return null; - } -} diff --git a/src/main/java/io/qdrant/client/utils/PointUtil.java b/src/main/java/io/qdrant/client/utils/PointUtil.java deleted file mode 100644 index e74b233f..00000000 --- a/src/main/java/io/qdrant/client/utils/PointUtil.java +++ /dev/null @@ -1,233 +0,0 @@ -package io.qdrant.client.utils; - -import io.qdrant.client.grpc.JsonWithInt.Value; -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.NamedVectors; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.PointStruct; -import io.qdrant.client.grpc.Points.PointsIdsList; -import io.qdrant.client.grpc.Points.PointsSelector; -import io.qdrant.client.grpc.Points.ReadConsistency; -import io.qdrant.client.grpc.Points.ReadConsistencyType; -import io.qdrant.client.grpc.Points.Vector; -import io.qdrant.client.grpc.Points.Vectors; -import io.qdrant.client.grpc.Points.WriteOrdering; -import io.qdrant.client.grpc.Points.WriteOrderingType; -import java.util.Arrays; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -/** Utility class for working with Points. */ -public class PointUtil { - - /** - * Creates a {@link PointsSelector} with point IDs specified as long values. - * - * @param pointIds The array of point IDs. - * @return The created PointsSelector. - */ - public static PointsSelector createPointsSelector(long... pointIds) { - - PointsIdsList pointsIdsList = - PointsIdsList.newBuilder() - .addAllIds( - Arrays.stream(pointIds).mapToObj(PointUtil::pointId).collect(Collectors.toList())) - .build(); - - return PointsSelector.newBuilder().setPoints(pointsIdsList).build(); - } - - /** - * Creates a {@link PointsSelector} with point IDs specified as strings. - * - * @param pointIds The array of point IDs. - * @return The created PointsSelector. - */ - public static PointsSelector createPointsSelector(String... pointIds) { - - // Validating the UUIDs - Arrays.stream(pointIds).forEach((String id) -> UUID.fromString(id)); - - // mapToObj() couldn't resolve the method overloads of createPointId() - // Using map() instead - PointsIdsList pointsIdsList = - PointsIdsList.newBuilder() - .addAllIds( - Arrays.stream(pointIds) - .map((String id) -> PointUtil.pointId(id)) - .collect(Collectors.toList())) - .build(); - - return PointsSelector.newBuilder().setPoints(pointsIdsList).build(); - } - - /** - * Creates a {@link PointsSelector} with point IDs specified as an iterable of {@link PointId}. - * - * @param pointIds The iterable of point IDs. - * @return The created PointsSelector. - */ - public static PointsSelector createPointsSelector(Iterable pointIds) { - PointsIdsList pointsIdsList = PointsIdsList.newBuilder().addAllIds(pointIds).build(); - - return PointsSelector.newBuilder().setPoints(pointsIdsList).build(); - } - - /** - * Creates a {@link PointsSelector} with a filter condition. - * - * @param filter The filter condition. - * @return The created PointsSelector. - */ - public static PointsSelector pointsSelector(Filter filter) { - return PointsSelector.newBuilder().setFilter(filter).build(); - } - - /** - * Creates a {@link PointId} with a long value. - * - * @param num The long value for the point ID. - * @return The created PointId. - * @throws IllegalArgumentException if the provided long value is negative. - */ - public static PointId pointId(long num) { - if (num < 0) { - throw new IllegalArgumentException("Point ID must be an unsigned integer or UUID"); - } - return PointId.newBuilder().setNum(num).build(); - } - - /** - * Creates a {@link PointId} with a string representing a UUID. - * - * @param uuid The string representation of the UUID. - * @return The created PointId. - * @throws IllegalArgumentException if the provided string is not a valid UUID. - */ - public static PointId pointId(String uuid) { - UUID.fromString(uuid); // Throws IllegalArgumentException if the string is not a valid UUID - return PointId.newBuilder().setUuid(uuid).build(); - } - - /** - * Creates a {@link PointId} with a {@link UUID}. - * - * @param uuid The UUID. - * @return The created PointId. - */ - public static PointId pointId(UUID uuid) { - return PointId.newBuilder().setUuid(uuid.toString()).build(); - } - - /** - * Creates a {@link PointStruct} with a UUID, a {@link Vector}, and payload data. - * - * @param uuid The UUID. - * @param vector The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct point(UUID uuid, Vector vector, Map payload) { - - return point(pointId(uuid), vector, payload); - } - - /** - * Creates a {@link PointStruct} with a long ID, a {@link Vector}, and payload data. - * - * @param id The long ID. - * @param vector The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct point(long id, Vector vector, Map payload) { - - return point(pointId(id), vector, payload); - } - - /** - * Creates a {@link PointStruct} with a UUID string, a {@link Vector}, and payload data. - * - * @param uuid The UUID string. - * @param vector The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct point(String uuid, Vector vector, Map payload) { - - return point(pointId(uuid), vector, payload); - } - - /** - * Creates a {@link PointStruct} with a {@link PointId}, a {@link Vector}, and payload data. - * - * @param id The PointId. - * @param vector The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct point(PointId id, Vector vector, Map payload) { - PointStruct.Builder builder = - PointStruct.newBuilder().setId(id).setVectors(Vectors.newBuilder().setVector(vector)); - if (payload != null) { - builder.putAllPayload(payload); - } - return builder.build(); - } - - /** - * Creates a named {@link PointStruct} with a long ID, vector name, vector data, and payload data. - * - * @param id The long ID. - * @param vectorName The name of the vector. - * @param vectorData The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct namedPoint( - Long id, String vectorName, float[] vectorData, Map payload) { - return namedPoint(pointId(id), vectorName, vectorData, payload); - } - - /** - * Creates a named {@link PointStruct} with a {@link PointId}, vector name, vector data, and - * payload data. - * - * @param id The PointId. - * @param vectorName The name of the vector. - * @param vectorData The vector data. - * @param payload The payload data. - * @return The created PointStruct. - */ - public static PointStruct namedPoint( - PointId id, String vectorName, float[] vectorData, Map payload) { - NamedVectors vectors = VectorUtil.namedVector(vectorName, vectorData); - PointStruct.Builder builder = - PointStruct.newBuilder().setId(id).setVectors(Vectors.newBuilder().setVectors(vectors)); - if (payload != null) { - builder.putAllPayload(payload); - } - return builder.build(); - } - - /** - * Creates a {@link WriteOrdering} with the specified ordering type. - * - * @param orderingType The ordering type. - * @return The created WriteOrdering. - */ - public static WriteOrdering ordering(WriteOrderingType orderingType) { - return WriteOrdering.newBuilder().setType(orderingType).build(); - } - - /** - * Creates a {@link ReadConsistency} with the specified consistency type. - * - * @param consistencyType The consistency type. - * @return The created ReadConsistency. - */ - public static ReadConsistency consistency(ReadConsistencyType consistencyType) { - return ReadConsistency.newBuilder().setType(consistencyType).build(); - } -} diff --git a/src/main/java/io/qdrant/client/utils/SelectorUtil.java b/src/main/java/io/qdrant/client/utils/SelectorUtil.java deleted file mode 100644 index 519e6c35..00000000 --- a/src/main/java/io/qdrant/client/utils/SelectorUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -package io.qdrant.client.utils; - -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.PayloadIncludeSelector; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.PointsIdsList; -import io.qdrant.client.grpc.Points.PointsSelector; -import io.qdrant.client.grpc.Points.VectorsSelector; -import io.qdrant.client.grpc.Points.WithPayloadSelector; -import io.qdrant.client.grpc.Points.WithVectorsSelector; -import java.util.Arrays; -import java.util.List; - -/** Utility class for working with Selectors. */ -public class SelectorUtil { - - /** - * Creates a {@link WithPayloadSelector} with the enable flag set to true. - * - * @return The created {@link WithPayloadSelector} object. - */ - public static WithPayloadSelector withPayload() { - return WithPayloadSelector.newBuilder().setEnable(true).build(); - } - - /** - * Creates a {@link WithVectorsSelector} with the enable flag set to true. - * - * @return The created {@link WithVectorsSelector} object. - */ - public static WithVectorsSelector withVectors() { - return WithVectorsSelector.newBuilder().setEnable(true).build(); - } - - /** - * Creates a {@link WithPayloadSelector} with the specified fields included in the payload. - * - * @param fields The fields to include in the payload. - * @return The created {@link WithPayloadSelector} object. - */ - public static WithPayloadSelector withPayload(String... fields) { - PayloadIncludeSelector include = - PayloadIncludeSelector.newBuilder().addAllFields(Arrays.asList(fields)).build(); - return WithPayloadSelector.newBuilder().setInclude(include).build(); - } - - /** - * Creates a {@link WithVectorsSelector} with the specified vector fields included. - * - * @param vectors The names of the vectors to include. - * @return The created {@link WithVectorsSelector} object. - */ - public static WithVectorsSelector withVectors(String... vectors) { - VectorsSelector include = - VectorsSelector.newBuilder().addAllNames(Arrays.asList(vectors)).build(); - return WithVectorsSelector.newBuilder().setInclude(include).build(); - } - - /** - * Creates a {@link PointsSelector} with the specified list of point IDs. - * - * @param ids The list of point IDs. - * @return The created {@link PointsSelector} object. - */ - public static PointsSelector idsSelector(List ids) { - return PointsSelector.newBuilder() - .setPoints(PointsIdsList.newBuilder().addAllIds(ids).build()) - .build(); - } - - /** - * Creates a {@link PointsSelector} with the specified array of point IDs. - * - * @param ids The array of point IDs. - * @return The created {@link PointsSelector} object. - */ - public static PointsSelector idsSelector(PointId... ids) { - return PointsSelector.newBuilder() - .setPoints(PointsIdsList.newBuilder().addAllIds(Arrays.asList(ids)).build()) - .build(); - } - - /** - * Creates a {@link PointsSelector} with the specified Filter. - * - * @param filter The Filter for the selector. - * @return The created {@link PointsSelector} object. - */ - public static PointsSelector filterSelector(Filter filter) { - return PointsSelector.newBuilder().setFilter(filter).build(); - } -} diff --git a/src/main/java/io/qdrant/client/utils/VectorUtil.java b/src/main/java/io/qdrant/client/utils/VectorUtil.java deleted file mode 100644 index d9657bf0..00000000 --- a/src/main/java/io/qdrant/client/utils/VectorUtil.java +++ /dev/null @@ -1,131 +0,0 @@ -package io.qdrant.client.utils; - -import io.qdrant.client.grpc.Points.NamedVectors; -import io.qdrant.client.grpc.Points.PointVectors; -import io.qdrant.client.grpc.Points.Vector; -import io.qdrant.client.grpc.Points.Vectors; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; - -/** Utility class for working with vector data. */ -public class VectorUtil { - - /** - * Creates a vector from a list of floats. - * - * @param vector The list of floats representing the vector. - * @return The created vector. - */ - public static Vector toVector(List vector) { - Vector.Builder vectorBuilder = Vector.newBuilder(); - return vectorBuilder.addAllData(vector).build(); - } - - /** - * Creates a vector from an array of floats. - * - * @param vector The array of floats representing the vector. - * @return The created vector. - */ - public static Vector toVector(float... vector) { - Vector.Builder vectorBuilder = Vector.newBuilder(); - for (Float f : vector) { - vectorBuilder.addData(f); - } - return vectorBuilder.build(); - } - - /** - * Creates a named vector from a list of floats. - * - * @param name The name of the vector. - * @param vector The list of floats representing the vector. - * @return The created named vector. - */ - public static NamedVectors namedVector(String name, List vector) { - NamedVectors.Builder namedVectorBuilder = NamedVectors.newBuilder(); - return namedVectorBuilder.putVectors(name, toVector(vector)).build(); - } - - /** - * Creates a named vector from an array of floats. - * - * @param name The name of the vector. - * @param vector The array of floats representing the vector. - * @return The created named vector. - */ - public static NamedVectors namedVector(String name, float... vector) { - NamedVectors.Builder namedVectorBuilder = NamedVectors.newBuilder(); - return namedVectorBuilder.putVectors(name, toVector(vector)).build(); - } - - /** - * Creates named vectors from a map of vector names to vectors. - * - * @param vectors The map of vector names to vectors. - * @return The created named vectors. - */ - public static NamedVectors namedVectors(Map vectors) { - NamedVectors.Builder namedVectorBuilder = NamedVectors.newBuilder(); - return namedVectorBuilder.putAllVectors(vectors).build(); - } - - /** - * Creates point vectors from an ID, name, and an array of floats. - * - * @param id The ID of the point vectors. - * @param name The name of the point vectors. - * @param vector The array of floats representing the point vectors. - * @return The created point vectors. - */ - public static PointVectors pointVectors(String id, String name, float... vector) { - PointVectors.Builder pointVectorsBuilder = PointVectors.newBuilder(); - Vectors vectors = Vectors.newBuilder().setVectors(namedVector(name, vector)).build(); - return pointVectorsBuilder.setId(PointUtil.pointId(id)).setVectors(vectors).build(); - } - - /** - * Generates dummy embeddings of the specified size. - * - * @param size The size of the embeddings to generate. - * @return An array of floats representing the generated embeddings. - * @throws IllegalArgumentException If the size is less than or equal to zero. - */ - public static List dummyEmbeddings(int size) { - if (size <= 0) { - throw new IllegalArgumentException("Size must be greater than zero"); - } - - List embeddings = new ArrayList<>(); - Random random = new Random(); - - for (int i = 0; i < size; i++) { - embeddings.add(random.nextFloat()); - } - - return embeddings; - } - - /** - * Generates a dummy vector of the specified size. - * - * @param size The size of the vector. - * @return The generated dummy vector. - */ - public static Vector dummyVector(int size) { - return toVector(dummyEmbeddings(size)); - } - - /** - * Generates a dummy named vector of the specified size. - * - * @param name The name of the vector. - * @param size The size of the vector. - * @return The generated dummy vector. - */ - public static NamedVectors dummyNamedVector(String name, int size) { - return namedVector(name, dummyEmbeddings(size)); - } -} diff --git a/src/main/proto/collections.proto b/src/main/proto/collections.proto deleted file mode 100644 index 67373bed..00000000 --- a/src/main/proto/collections.proto +++ /dev/null @@ -1,448 +0,0 @@ -syntax = "proto3"; -package qdrant; - -option java_package = "io.qdrant.client.grpc"; - -message VectorParams { - uint64 size = 1; // Size of the vectors - Distance distance = 2; // Distance function used for comparing vectors - optional HnswConfigDiff hnsw_config = 3; // Configuration of vector HNSW graph. If omitted - the collection configuration will be used - optional QuantizationConfig quantization_config = 4; // Configuration of vector quantization config. If omitted - the collection configuration will be used - optional bool on_disk = 5; // If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. -} - -message VectorParamsDiff { - optional HnswConfigDiff hnsw_config = 1; // Update params for HNSW index. If empty object - it will be unset - optional QuantizationConfigDiff quantization_config = 2; // Update quantization params. If none - it is left unchanged. - optional bool on_disk = 3; // If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. -} - -message VectorParamsMap { - map map = 1; -} - -message VectorParamsDiffMap { - map map = 1; -} - -message VectorsConfig { - oneof config { - VectorParams params = 1; - VectorParamsMap params_map = 2; - } -} - -message VectorsConfigDiff { - oneof config { - VectorParamsDiff params = 1; - VectorParamsDiffMap params_map = 2; - } -} - -message GetCollectionInfoRequest { - string collection_name = 1; // Name of the collection -} - -message ListCollectionsRequest { -} - -message CollectionDescription { - string name = 1; // Name of the collection -} - -message GetCollectionInfoResponse { - CollectionInfo result = 1; - double time = 2; // Time spent to process -} - -message ListCollectionsResponse { - repeated CollectionDescription collections = 1; - double time = 2; // Time spent to process -} - -enum Distance { - UnknownDistance = 0; - Cosine = 1; - Euclid = 2; - Dot = 3; -} - -enum CollectionStatus { - UnknownCollectionStatus = 0; - Green = 1; // All segments are ready - Yellow = 2; // Optimization in process - Red = 3; // Something went wrong -} - -enum PayloadSchemaType { - UnknownType = 0; - Keyword = 1; - Integer = 2; - Float = 3; - Geo = 4; - Text = 5; - Bool = 6; -} - -enum QuantizationType { - UnknownQuantization = 0; - Int8 = 1; -} - -enum CompressionRatio { - x4 = 0; - x8 = 1; - x16 = 2; - x32 = 3; - x64 = 4; -} - -message OptimizerStatus { - bool ok = 1; - string error = 2; -} - -message HnswConfigDiff { - /* - Number of edges per node in the index graph. Larger the value - more accurate the search, more space required. - */ - optional uint64 m = 1; - /* - Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index. - */ - optional uint64 ef_construct = 2; - /* - Minimal size (in KiloBytes) of vectors for additional payload-based indexing. - If the payload chunk is smaller than `full_scan_threshold` additional indexing won't be used - - in this case full-scan search should be preferred by query planner and additional indexing is not required. - Note: 1 Kb = 1 vector of size 256 - */ - optional uint64 full_scan_threshold = 3; - /* - Number of parallel threads used for background index building. If 0 - auto selection. - */ - optional uint64 max_indexing_threads = 4; - /* - Store HNSW index on disk. If set to false, the index will be stored in RAM. - */ - optional bool on_disk = 5; - /* - Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used. - */ - optional uint64 payload_m = 6; -} - -message WalConfigDiff { - optional uint64 wal_capacity_mb = 1; // Size of a single WAL block file - optional uint64 wal_segments_ahead = 2; // Number of segments to create in advance -} - -message OptimizersConfigDiff { - /* - The minimal fraction of deleted vectors in a segment, required to perform segment optimization - */ - optional double deleted_threshold = 1; - /* - The minimal number of vectors in a segment, required to perform segment optimization - */ - optional uint64 vacuum_min_vector_number = 2; - /* - Target amount of segments the optimizer will try to keep. - Real amount of segments may vary depending on multiple parameters: - - - Amount of stored points. - - Current write RPS. - - It is recommended to select the default number of segments as a factor of the number of search threads, - so that each segment would be handled evenly by one of the threads. - */ - optional uint64 default_segment_number = 3; - /* - Do not create segments larger this size (in kilobytes). - Large segments might require disproportionately long indexation times, - therefore it makes sense to limit the size of segments. - - If indexing speed is more important - make this parameter lower. - If search speed is more important - make this parameter higher. - Note: 1Kb = 1 vector of size 256 - If not set, will be automatically selected considering the number of available CPUs. - */ - optional uint64 max_segment_size = 4; - /* - Maximum size (in kilobytes) of vectors to store in-memory per segment. - Segments larger than this threshold will be stored as read-only memmaped file. - - Memmap storage is disabled by default, to enable it, set this threshold to a reasonable value. - - To disable memmap storage, set this to `0`. - - Note: 1Kb = 1 vector of size 256 - */ - optional uint64 memmap_threshold = 5; - /* - Maximum size (in kilobytes) of vectors allowed for plain index, exceeding this threshold will enable vector indexing - - Default value is 20,000, based on . - - To disable vector indexing, set to `0`. - - Note: 1kB = 1 vector of size 256. - */ - optional uint64 indexing_threshold = 6; - /* - Interval between forced flushes. - */ - optional uint64 flush_interval_sec = 7; - /* - Max number of threads, which can be used for optimization. If 0 - `NUM_CPU - 1` will be used - */ - optional uint64 max_optimization_threads = 8; -} - -message ScalarQuantization { - QuantizationType type = 1; // Type of quantization - optional float quantile = 2; // Number of bits to use for quantization - optional bool always_ram = 3; // If true - quantized vectors always will be stored in RAM, ignoring the config of main storage -} - -message ProductQuantization { - CompressionRatio compression = 1; // Compression ratio - optional bool always_ram = 2; // If true - quantized vectors always will be stored in RAM, ignoring the config of main storage -} - -message BinaryQuantization { - optional bool always_ram = 1; // If true - quantized vectors always will be stored in RAM, ignoring the config of main storage -} - -message QuantizationConfig { - oneof quantization { - ScalarQuantization scalar = 1; - ProductQuantization product = 2; - BinaryQuantization binary = 3; - } -} - -message Disabled { - -} - -message QuantizationConfigDiff { - oneof quantization { - ScalarQuantization scalar = 1; - ProductQuantization product = 2; - Disabled disabled = 3; - BinaryQuantization binary = 4; - } -} - -message CreateCollection { - string collection_name = 1; // Name of the collection - reserved 2; // Deprecated - reserved 3; // Deprecated - optional HnswConfigDiff hnsw_config = 4; // Configuration of vector index - optional WalConfigDiff wal_config = 5; // Configuration of the Write-Ahead-Log - optional OptimizersConfigDiff optimizers_config = 6; // Configuration of the optimizers - optional uint32 shard_number = 7; // Number of shards in the collection, default is 1 for standalone, otherwise equal to the number of nodes. Minimum is 1 - optional bool on_disk_payload = 8; // If true - point's payload will not be stored in memory - optional uint64 timeout = 9; // Wait timeout for operation commit in seconds, if not specified - default value will be supplied - optional VectorsConfig vectors_config = 10; // Configuration for vectors - optional uint32 replication_factor = 11; // Number of replicas of each shard that network tries to maintain, default = 1 - optional uint32 write_consistency_factor = 12; // How many replicas should apply the operation for us to consider it successful, default = 1 - optional string init_from_collection = 13; // Specify name of the other collection to copy data from - optional QuantizationConfig quantization_config = 14; // Quantization configuration of vector -} - -message UpdateCollection { - string collection_name = 1; // Name of the collection - optional OptimizersConfigDiff optimizers_config = 2; // New configuration parameters for the collection. This operation is blocking, it will only proceed once all current optimizations are complete - optional uint64 timeout = 3; // Wait timeout for operation commit in seconds if blocking, if not specified - default value will be supplied - optional CollectionParamsDiff params = 4; // New configuration parameters for the collection - optional HnswConfigDiff hnsw_config = 5; // New HNSW parameters for the collection index - optional VectorsConfigDiff vectors_config = 6; // New vector parameters - optional QuantizationConfigDiff quantization_config = 7; // Quantization configuration of vector -} - -message DeleteCollection { - string collection_name = 1; // Name of the collection - optional uint64 timeout = 2; // Wait timeout for operation commit in seconds, if not specified - default value will be supplied -} - -message CollectionOperationResponse { - bool result = 1; // if operation made changes - double time = 2; // Time spent to process -} - -message CollectionParams { - reserved 1; // Deprecated - reserved 2; // Deprecated - uint32 shard_number = 3; // Number of shards in collection - bool on_disk_payload = 4; // If true - point's payload will not be stored in memory - optional VectorsConfig vectors_config = 5; // Configuration for vectors - optional uint32 replication_factor = 6; // Number of replicas of each shard that network tries to maintain - optional uint32 write_consistency_factor = 7; // How many replicas should apply the operation for us to consider it successful - optional uint32 read_fan_out_factor = 8; // Fan-out every read request to these many additional remote nodes (and return first available response) -} - -message CollectionParamsDiff { - optional uint32 replication_factor = 1; // Number of replicas of each shard that network tries to maintain - optional uint32 write_consistency_factor = 2; // How many replicas should apply the operation for us to consider it successful - optional bool on_disk_payload = 3; // If true - point's payload will not be stored in memory - optional uint32 read_fan_out_factor = 4; // Fan-out every read request to these many additional remote nodes (and return first available response) -} - -message CollectionConfig { - CollectionParams params = 1; // Collection parameters - HnswConfigDiff hnsw_config = 2; // Configuration of vector index - OptimizersConfigDiff optimizer_config = 3; // Configuration of the optimizers - WalConfigDiff wal_config = 4; // Configuration of the Write-Ahead-Log - optional QuantizationConfig quantization_config = 5; // Configuration of the vector quantization -} - -enum TokenizerType { - Unknown = 0; - Prefix = 1; - Whitespace = 2; - Word = 3; - Multilingual = 4; -} - -message TextIndexParams { - TokenizerType tokenizer = 1; // Tokenizer type - optional bool lowercase = 2; // If true - all tokens will be lowercase - optional uint64 min_token_len = 3; // Minimal token length - optional uint64 max_token_len = 4; // Maximal token length -} - -message PayloadIndexParams { - oneof index_params { - TextIndexParams text_index_params = 1; // Parameters for text index - } -} - -message PayloadSchemaInfo { - PayloadSchemaType data_type = 1; // Field data type - optional PayloadIndexParams params = 2; // Field index parameters - optional uint64 points = 3; // Number of points indexed within this field indexed -} - -message CollectionInfo { - CollectionStatus status = 1; // operating condition of the collection - OptimizerStatus optimizer_status = 2; // status of collection optimizers - uint64 vectors_count = 3; // number of vectors in the collection - uint64 segments_count = 4; // Number of independent segments - reserved 5; // Deprecated - reserved 6; // Deprecated - CollectionConfig config = 7; // Configuration - map payload_schema = 8; // Collection data types - uint64 points_count = 9; // number of points in the collection - optional uint64 indexed_vectors_count = 10; // number of indexed vectors in the collection. -} - -message ChangeAliases { - repeated AliasOperations actions = 1; // List of actions - optional uint64 timeout = 2; // Wait timeout for operation commit in seconds, if not specified - default value will be supplied -} - -message AliasOperations { - oneof action { - CreateAlias create_alias = 1; - RenameAlias rename_alias = 2; - DeleteAlias delete_alias = 3; - } -} - -message CreateAlias { - string collection_name = 1; // Name of the collection - string alias_name = 2; // New name of the alias -} - -message RenameAlias { - string old_alias_name = 1; // Name of the alias to rename - string new_alias_name = 2; // Name of the alias -} - -message DeleteAlias { - string alias_name = 1; // Name of the alias -} - -message ListAliasesRequest { -} - -message ListCollectionAliasesRequest { - string collection_name = 1; // Name of the collection -} - -message AliasDescription { - string alias_name = 1; // Name of the alias - string collection_name = 2; // Name of the collection -} - -message ListAliasesResponse { - repeated AliasDescription aliases = 1; - double time = 2; // Time spent to process -} - -message CollectionClusterInfoRequest { - string collection_name = 1; // Name of the collection -} - -enum ReplicaState { - Active = 0; // Active and sound - Dead = 1; // Failed for some reason - Partial = 2; // The shard is partially loaded and is currently receiving data from other shards - Initializing = 3; // Collection is being created - Listener = 4; // A shard which receives data, but is not used for search; Useful for backup shards -} - -message LocalShardInfo { - uint32 shard_id = 1; // Local shard id - uint64 points_count = 2; // Number of points in the shard - ReplicaState state = 3; // Is replica active -} - -message RemoteShardInfo { - uint32 shard_id = 1; // Local shard id - uint64 peer_id = 2; // Remote peer id - ReplicaState state = 3; // Is replica active -} - -message ShardTransferInfo { - uint32 shard_id = 1; // Local shard id - uint64 from = 2; - uint64 to = 3; - bool sync = 4; // If `true` transfer is a synchronization of a replicas; If `false` transfer is a moving of a shard from one peer to another -} - -message CollectionClusterInfoResponse { - uint64 peer_id = 1; // ID of this peer - uint64 shard_count = 2; // Total number of shards - repeated LocalShardInfo local_shards = 3; // Local shards - repeated RemoteShardInfo remote_shards = 4; // Remote shards - repeated ShardTransferInfo shard_transfers = 5; // Shard transfers -} - -message MoveShard { - uint32 shard_id = 1; // Local shard id - uint64 from_peer_id = 2; - uint64 to_peer_id = 3; -} - -message Replica { - uint32 shard_id = 1; - uint64 peer_id = 2; -} - -message UpdateCollectionClusterSetupRequest { - string collection_name = 1; // Name of the collection - oneof operation { - MoveShard move_shard = 2; - MoveShard replicate_shard = 3; - MoveShard abort_transfer = 4; - Replica drop_replica = 5; - } - optional uint64 timeout = 6; // Wait timeout for operation commit in seconds, if not specified - default value will be supplied -} - -message UpdateCollectionClusterSetupResponse { - bool result = 1; -} diff --git a/src/main/proto/collections_service.proto b/src/main/proto/collections_service.proto deleted file mode 100644 index d5a106ad..00000000 --- a/src/main/proto/collections_service.proto +++ /dev/null @@ -1,50 +0,0 @@ -syntax = "proto3"; - -import "collections.proto"; - -option java_package = "io.qdrant.client.grpc"; - -package qdrant; - -service Collections { - /* - Get detailed information about specified existing collection - */ - rpc Get (GetCollectionInfoRequest) returns (GetCollectionInfoResponse) {} - /* - Get list name of all existing collections - */ - rpc List (ListCollectionsRequest) returns (ListCollectionsResponse) {} - /* - Create new collection with given parameters - */ - rpc Create (CreateCollection) returns (CollectionOperationResponse) {} - /* - Update parameters of the existing collection - */ - rpc Update (UpdateCollection) returns (CollectionOperationResponse) {} - /* - Drop collection and all associated data - */ - rpc Delete (DeleteCollection) returns (CollectionOperationResponse) {} - /* - Update Aliases of the existing collection - */ - rpc UpdateAliases (ChangeAliases) returns (CollectionOperationResponse) {} - /* - Get list of all aliases for a collection - */ - rpc ListCollectionAliases (ListCollectionAliasesRequest) returns (ListAliasesResponse) {} - /* - Get list of all aliases for all existing collections - */ - rpc ListAliases (ListAliasesRequest) returns (ListAliasesResponse) {} - /* - Get cluster information for a collection - */ - rpc CollectionClusterInfo (CollectionClusterInfoRequest) returns (CollectionClusterInfoResponse) {} - /* - Update cluster setup for a collection - */ - rpc UpdateCollectionClusterSetup (UpdateCollectionClusterSetupRequest) returns (UpdateCollectionClusterSetupResponse) {} -} diff --git a/src/main/proto/json_with_int.proto b/src/main/proto/json_with_int.proto deleted file mode 100644 index c9fecb06..00000000 --- a/src/main/proto/json_with_int.proto +++ /dev/null @@ -1,63 +0,0 @@ -// Fork of the google.protobuf.Value with explicit support for integer values - -syntax = "proto3"; - -package qdrant; - -option java_package = "io.qdrant.client.grpc"; - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is a JSON object. -message Struct { - // Unordered map of dynamically typed values. - map fields = 1; -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of those -// variants, absence of any variant indicates an error. -// -// The JSON representation for `Value` is a JSON value. -message Value { - // The kind of value. - oneof kind { - // Represents a null value. - NullValue null_value = 1; - // Represents a double value. - double double_value = 2; - // Represents an integer value - int64 integer_value = 3; - // Represents a string value. - string string_value = 4; - // Represents a boolean value. - bool bool_value = 5; - // Represents a structured value. - Struct struct_value = 6; - // Represents a repeated `Value`. - ListValue list_value = 7; - } -} - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -enum NullValue { - // Null value. - NULL_VALUE = 0; -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is a JSON array. -message ListValue { - // Repeated field of dynamically typed values. - repeated Value values = 1; -} diff --git a/src/main/proto/points.proto b/src/main/proto/points.proto deleted file mode 100644 index b7b5ec4c..00000000 --- a/src/main/proto/points.proto +++ /dev/null @@ -1,646 +0,0 @@ -syntax = "proto3"; - -package qdrant; - -option java_package = "io.qdrant.client.grpc"; - -import "json_with_int.proto"; -import "collections.proto"; - - -enum WriteOrderingType { - Weak = 0; // Write operations may be reordered, works faster, default - Medium = 1; // Write operations go through dynamically selected leader, may be inconsistent for a short period of time in case of leader change - Strong = 2; // Write operations go through the permanent leader, consistent, but may be unavailable if leader is down -} - -message WriteOrdering { - WriteOrderingType type = 1; // Write ordering guarantees -} - -enum ReadConsistencyType { - All = 0; // Send request to all nodes and return points which are present on all of them - Majority = 1; // Send requests to all nodes and return points which are present on majority of them - Quorum = 2; // Send requests to half + 1 nodes, return points which are present on all of them -} - -message ReadConsistency { - oneof value { - ReadConsistencyType type = 1; // Common read consistency configurations - uint64 factor = 2; // Send request to a specified number of nodes, and return points which are present on all of them - } -} - -// --------------------------------------------- -// ------------- Point Id Requests ------------- -// --------------------------------------------- - -message PointId { - oneof point_id_options { - uint64 num = 1; // Numerical ID of the point - string uuid = 2; // UUID - } -} - -message Vector { - repeated float data = 1; -} - -// --------------------------------------------- -// ---------------- RPC Requests --------------- -// --------------------------------------------- - -message UpsertPoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - repeated PointStruct points = 3; - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -message DeletePoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - PointsSelector points = 3; // Affected points - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -message GetPoints { - string collection_name = 1; // name of the collection - repeated PointId ids = 2; // List of points to retrieve - reserved 3; // deprecated "with_vector" field - WithPayloadSelector with_payload = 4; // Options for specifying which payload to include or not - optional WithVectorsSelector with_vectors = 5; // Options for specifying which vectors to include into response - optional ReadConsistency read_consistency = 6; // Options for specifying read consistency guarantees -} - -message UpdatePointVectors { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - repeated PointVectors points = 3; // List of points and vectors to update - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -message PointVectors { - PointId id = 1; // ID to update vectors for - Vectors vectors = 2; // Named vectors to update, leave others intact -} - -message DeletePointVectors { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - PointsSelector points_selector = 3; // Affected points - VectorsSelector vectors = 4; // List of vector names to delete - optional WriteOrdering ordering = 5; // Write ordering guarantees -} - -message SetPayloadPoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - map payload = 3; // New payload values - reserved 4; // List of point to modify, deprecated - optional PointsSelector points_selector = 5; // Affected points - optional WriteOrdering ordering = 6; // Write ordering guarantees -} - -message DeletePayloadPoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - repeated string keys = 3; // List of keys to delete - reserved 4; // Affected points, deprecated - optional PointsSelector points_selector = 5; // Affected points - optional WriteOrdering ordering = 6; // Write ordering guarantees -} - -message ClearPayloadPoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - PointsSelector points = 3; // Affected points - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -enum FieldType { - FieldTypeKeyword = 0; - FieldTypeInteger = 1; - FieldTypeFloat = 2; - FieldTypeGeo = 3; - FieldTypeText = 4; - FieldTypeBool = 5; -} - -message CreateFieldIndexCollection { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - string field_name = 3; // Field name to index - optional FieldType field_type = 4; // Field type. - optional PayloadIndexParams field_index_params = 5; // Payload index params. - optional WriteOrdering ordering = 6; // Write ordering guarantees -} - -message DeleteFieldIndexCollection { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - string field_name = 3; // Field name to delete - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -message PayloadIncludeSelector { - repeated string fields = 1; // List of payload keys to include into result -} - -message PayloadExcludeSelector { - repeated string fields = 1; // List of payload keys to exclude from the result -} - -message WithPayloadSelector { - oneof selector_options { - bool enable = 1; // If `true` - return all payload, if `false` - none - PayloadIncludeSelector include = 2; - PayloadExcludeSelector exclude = 3; - } -} - -message NamedVectors { - map vectors = 1; -} - -message Vectors { - oneof vectors_options { - Vector vector = 1; - NamedVectors vectors = 2; - } -} - -message VectorsSelector { - repeated string names = 1; // List of vectors to include into result -} - -message WithVectorsSelector { - oneof selector_options { - bool enable = 1; // If `true` - return all vectors, if `false` - none - VectorsSelector include = 2; // List of payload keys to include into result - } -} - -message QuantizationSearchParams { - /* - If set to true, search will ignore quantized vector data - */ - optional bool ignore = 1; - - /* - If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not. - */ - optional bool rescore = 2; - - /* - Oversampling factor for quantization. - - Defines how many extra vectors should be pre-selected using quantized index, - and then re-scored using original vectors. - - For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will be pre-selected using quantized index, - and then top-100 will be returned after re-scoring. - */ - optional double oversampling = 3; -} - -message SearchParams { - /* - Params relevant to HNSW index. Size of the beam in a beam-search. - Larger the value - more accurate the result, more time required for search. - */ - optional uint64 hnsw_ef = 1; - - /* - Search without approximation. If set to true, search may run long but with exact results. - */ - optional bool exact = 2; - - /* - If set to true, search will ignore quantized vector data - */ - optional QuantizationSearchParams quantization = 3; - /* - If enabled, the engine will only perform search among indexed or small segments. - Using this option prevents slow searches in case of delayed index, but does not - guarantee that all uploaded vectors will be included in search results - */ - optional bool indexed_only = 4; -} - -message SearchPoints { - string collection_name = 1; // name of the collection - repeated float vector = 2; // vector - Filter filter = 3; // Filter conditions - return only those points that satisfy the specified conditions - uint64 limit = 4; // Max number of result - reserved 5; // deprecated "with_vector" field - WithPayloadSelector with_payload = 6; // Options for specifying which payload to include or not - SearchParams params = 7; // Search config - optional float score_threshold = 8; // If provided - cut off results with worse scores - optional uint64 offset = 9; // Offset of the result - optional string vector_name = 10; // Which vector to use for search, if not specified - use default vector - optional WithVectorsSelector with_vectors = 11; // Options for specifying which vectors to include into response - optional ReadConsistency read_consistency = 12; // Options for specifying read consistency guarantees -} - -message SearchBatchPoints { - string collection_name = 1; // Name of the collection - repeated SearchPoints search_points = 2; - optional ReadConsistency read_consistency = 3; // Options for specifying read consistency guarantees -} - -message WithLookup { - string collection = 1; // Name of the collection to use for points lookup - optional WithPayloadSelector with_payload = 2; // Options for specifying which payload to include (or not) - optional WithVectorsSelector with_vectors = 3; // Options for specifying which vectors to include (or not) -} - - -message SearchPointGroups { - string collection_name = 1; // Name of the collection - repeated float vector = 2; // Vector to compare against - Filter filter = 3; // Filter conditions - return only those points that satisfy the specified conditions - uint32 limit = 4; // Max number of result - WithPayloadSelector with_payload = 5; // Options for specifying which payload to include or not - SearchParams params = 6; // Search config - optional float score_threshold = 7; // If provided - cut off results with worse scores - optional string vector_name = 8; // Which vector to use for search, if not specified - use default vector - optional WithVectorsSelector with_vectors = 9; // Options for specifying which vectors to include into response - string group_by = 10; // Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. - uint32 group_size = 11; // Maximum amount of points to return per group - optional ReadConsistency read_consistency = 12; // Options for specifying read consistency guarantees - optional WithLookup with_lookup = 13; // Options for specifying how to use the group id to lookup points in another collection -} - -message ScrollPoints { - string collection_name = 1; - Filter filter = 2; // Filter conditions - return only those points that satisfy the specified conditions - optional PointId offset = 3; // Start with this ID - optional uint32 limit = 4; // Max number of result - reserved 5; // deprecated "with_vector" field - WithPayloadSelector with_payload = 6; // Options for specifying which payload to include or not - optional WithVectorsSelector with_vectors = 7; // Options for specifying which vectors to include into response - optional ReadConsistency read_consistency = 8; // Options for specifying read consistency guarantees -} - -// How to use positive and negative vectors to find the results, default is `AverageVector`: -enum RecommendStrategy { - // Average positive and negative vectors and create a single query with the formula - // `query = avg_pos + avg_pos - avg_neg`. Then performs normal search. - AverageVector = 0; - - // Uses custom search objective. Each candidate is compared against all - // examples, its score is then chosen from the `max(max_pos_score, max_neg_score)`. - // If the `max_neg_score` is chosen then it is squared and negated. - BestScore = 1; -} - -message LookupLocation { - string collection_name = 1; - optional string vector_name = 2; // Which vector to use for search, if not specified - use default vector -} - -message RecommendPoints { - string collection_name = 1; // name of the collection - repeated PointId positive = 2; // Look for vectors closest to the vectors from these points - repeated PointId negative = 3; // Try to avoid vectors like the vector from these points - Filter filter = 4; // Filter conditions - return only those points that satisfy the specified conditions - uint64 limit = 5; // Max number of result - reserved 6; // deprecated "with_vector" field - WithPayloadSelector with_payload = 7; // Options for specifying which payload to include or not - SearchParams params = 8; // Search config - optional float score_threshold = 9; // If provided - cut off results with worse scores - optional uint64 offset = 10; // Offset of the result - optional string using = 11; // Define which vector to use for recommendation, if not specified - default vector - optional WithVectorsSelector with_vectors = 12; // Options for specifying which vectors to include into response - optional LookupLocation lookup_from = 13; // Name of the collection to use for points lookup, if not specified - use current collection - optional ReadConsistency read_consistency = 14; // Options for specifying read consistency guarantees - optional RecommendStrategy strategy = 16; // How to use the example vectors to find the results - repeated Vector positive_vectors = 17; // Look for vectors closest to those - repeated Vector negative_vectors = 18; // Try to avoid vectors like this -} - -message RecommendBatchPoints { - string collection_name = 1; // Name of the collection - repeated RecommendPoints recommend_points = 2; - optional ReadConsistency read_consistency = 3; // Options for specifying read consistency guarantees -} - -message RecommendPointGroups { - string collection_name = 1; // Name of the collection - repeated PointId positive = 2; // Look for vectors closest to the vectors from these points - repeated PointId negative = 3; // Try to avoid vectors like the vector from these points - Filter filter = 4; // Filter conditions - return only those points that satisfy the specified conditions - uint32 limit = 5; // Max number of groups in result - WithPayloadSelector with_payload = 6; // Options for specifying which payload to include or not - SearchParams params = 7; // Search config - optional float score_threshold = 8; // If provided - cut off results with worse scores - optional string using = 9; // Define which vector to use for recommendation, if not specified - default vector - optional WithVectorsSelector with_vectors = 10; // Options for specifying which vectors to include into response - optional LookupLocation lookup_from = 11; // Name of the collection to use for points lookup, if not specified - use current collection - string group_by = 12; // Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. - uint32 group_size = 13; // Maximum amount of points to return per group - optional ReadConsistency read_consistency = 14; // Options for specifying read consistency guarantees - optional WithLookup with_lookup = 15; // Options for specifying how to use the group id to lookup points in another collection - optional RecommendStrategy strategy = 17; // How to use the example vectors to find the results - repeated Vector positive_vectors = 18; // Look for vectors closest to those - repeated Vector negative_vectors = 19; // Try to avoid vectors like this -} - -message CountPoints { - string collection_name = 1; // name of the collection - Filter filter = 2; // Filter conditions - return only those points that satisfy the specified conditions - optional bool exact = 3; // If `true` - return exact count, if `false` - return approximate count -} - -message PointsUpdateOperation { - message PointStructList { - repeated PointStruct points = 1; - } - message SetPayload { - map payload = 1; - optional PointsSelector points_selector = 2; // Affected points - } - message DeletePayload { - repeated string keys = 1; - optional PointsSelector points_selector = 2; // Affected points - } - message UpdateVectors { - repeated PointVectors points = 1; // List of points and vectors to update - } - message DeleteVectors { - PointsSelector points_selector = 1; // Affected points - VectorsSelector vectors = 2; // List of vector names to delete - } - - oneof operation { - PointStructList upsert = 1; - PointsSelector delete = 2; - SetPayload set_payload = 3; - SetPayload overwrite_payload = 4; - DeletePayload delete_payload = 5; - PointsSelector clear_payload = 6; - UpdateVectors update_vectors = 7; - DeleteVectors delete_vectors = 8; - } -} - -message UpdateBatchPoints { - string collection_name = 1; // name of the collection - optional bool wait = 2; // Wait until the changes have been applied? - repeated PointsUpdateOperation operations = 3; - optional WriteOrdering ordering = 4; // Write ordering guarantees -} - -// --------------------------------------------- -// ---------------- RPC Response --------------- -// --------------------------------------------- - -message PointsOperationResponse { - UpdateResult result = 1; - double time = 2; // Time spent to process -} - -message UpdateResult { - uint64 operation_id = 1; // Number of operation - UpdateStatus status = 2; // Operation status -} - -enum UpdateStatus { - UnknownUpdateStatus = 0; - Acknowledged = 1; // Update is received, but not processed yet - Completed = 2; // Update is applied and ready for search -} - -message ScoredPoint { - PointId id = 1; // Point id - map payload = 2; // Payload - float score = 3; // Similarity score - reserved 4; // deprecated "vector" field - uint64 version = 5; // Last update operation applied to this point - optional Vectors vectors = 6; // Vectors to search -} - -message GroupId { - oneof kind { - // Represents a double value. - uint64 unsigned_value = 1; - // Represents an integer value - int64 integer_value = 2; - // Represents a string value. - string string_value = 3; - } -} - -message PointGroup { - GroupId id = 1; // Group id - repeated ScoredPoint hits = 2; // Points in the group - RetrievedPoint lookup = 3; // Point(s) from the lookup collection that matches the group id -} - -message GroupsResult { - repeated PointGroup groups = 1; // Groups -} - -message SearchResponse { - repeated ScoredPoint result = 1; - double time = 2; // Time spent to process -} - -message BatchResult { - repeated ScoredPoint result = 1; -} - -message SearchBatchResponse { - repeated BatchResult result = 1; - double time = 2; // Time spent to process -} - -message SearchGroupsResponse { - GroupsResult result = 1; - double time = 2; // Time spent to process -} - -message CountResponse { - CountResult result = 1; - double time = 2; // Time spent to process -} - -message ScrollResponse { - optional PointId next_page_offset = 1; // Use this offset for the next query - repeated RetrievedPoint result = 2; - double time = 3; // Time spent to process -} - -message CountResult { - uint64 count = 1; -} - -message RetrievedPoint { - PointId id = 1; - map payload = 2; - reserved 3; // deprecated "vector" field - optional Vectors vectors = 4; -} - -message GetResponse { - repeated RetrievedPoint result = 1; - double time = 2; // Time spent to process -} - -message RecommendResponse { - repeated ScoredPoint result = 1; - double time = 2; // Time spent to process -} - -message RecommendBatchResponse { - repeated BatchResult result = 1; - double time = 2; // Time spent to process -} - -message RecommendGroupsResponse { - GroupsResult result = 1; - double time = 2; // Time spent to process -} - -message UpdateBatchResponse { - repeated UpdateResult result = 1; - double time = 2; // Time spent to process -} - -// --------------------------------------------- -// ------------- Filter Conditions ------------- -// --------------------------------------------- - -message Filter { - repeated Condition should = 1; // At least one of those conditions should match - repeated Condition must = 2; // All conditions must match - repeated Condition must_not = 3; // All conditions must NOT match -} - -message Condition { - oneof condition_one_of { - FieldCondition field = 1; - IsEmptyCondition is_empty = 2; - HasIdCondition has_id = 3; - Filter filter = 4; - IsNullCondition is_null = 5; - NestedCondition nested = 6; - } -} - -message IsEmptyCondition { - string key = 1; -} - -message IsNullCondition { - string key = 1; -} - -message HasIdCondition { - repeated PointId has_id = 1; -} - -message NestedCondition { - string key = 1; // Path to nested object - Filter filter = 2; // Filter condition -} - -message FieldCondition { - string key = 1; - Match match = 2; // Check if point has field with a given value - Range range = 3; // Check if points value lies in a given range - GeoBoundingBox geo_bounding_box = 4; // Check if points geolocation lies in a given area - GeoRadius geo_radius = 5; // Check if geo point is within a given radius - ValuesCount values_count = 6; // Check number of values for a specific field - GeoPolygon geo_polygon = 7; // Check if geo point is within a given polygon -} - -message Match { - oneof match_value { - string keyword = 1; // Match string keyword - int64 integer = 2; // Match integer - bool boolean = 3; // Match boolean - string text = 4; // Match text - RepeatedStrings keywords = 5; // Match multiple keywords - RepeatedIntegers integers = 6; // Match multiple integers - RepeatedIntegers except_integers = 7; // Match any other value except those integers - RepeatedStrings except_keywords = 8; // Match any other value except those keywords - } -} - -message RepeatedStrings { - repeated string strings = 1; -} - -message RepeatedIntegers { - repeated int64 integers = 1; -} - -message Range { - optional double lt = 1; - optional double gt = 2; - optional double gte = 3; - optional double lte = 4; -} - -message GeoBoundingBox { - GeoPoint top_left = 1; // north-west corner - GeoPoint bottom_right = 2; // south-east corner -} - -message GeoRadius { - GeoPoint center = 1; // Center of the circle - float radius = 2; // In meters -} - -message GeoLineString { - repeated GeoPoint points = 1; // Ordered sequence of GeoPoints representing the line -} - -// For a valid GeoPolygon, both the exterior and interior GeoLineStrings must consist of a minimum of 4 points. -// Additionally, the first and last points of each GeoLineString must be the same. -message GeoPolygon { - GeoLineString exterior = 1; // The exterior line bounds the surface - repeated GeoLineString interiors = 2; // Interior lines (if present) bound holes within the surface -} - -message ValuesCount { - optional uint64 lt = 1; - optional uint64 gt = 2; - optional uint64 gte = 3; - optional uint64 lte = 4; -} - -// --------------------------------------------- -// -------------- Points Selector -------------- -// --------------------------------------------- - -message PointsSelector { - oneof points_selector_one_of { - PointsIdsList points = 1; - Filter filter = 2; - } -} - -message PointsIdsList { - repeated PointId ids = 1; -} - -// --------------------------------------------- -// ------------------- Point ------------------- -// --------------------------------------------- - - -message PointStruct { - PointId id = 1; - reserved 2; // deprecated "vector" field - map payload = 3; - optional Vectors vectors = 4; -} - - -message GeoPoint { - double lon = 1; - double lat = 2; -} diff --git a/src/main/proto/points_service.proto b/src/main/proto/points_service.proto deleted file mode 100644 index 79c15937..00000000 --- a/src/main/proto/points_service.proto +++ /dev/null @@ -1,93 +0,0 @@ -syntax = "proto3"; - -import "points.proto"; - -package qdrant; - -option java_package = "io.qdrant.client.grpc"; - -import "google/protobuf/struct.proto"; - -service Points { - /* - Perform insert + updates on points. If a point with a given ID already exists - it will be overwritten. - */ - rpc Upsert (UpsertPoints) returns (PointsOperationResponse) {} - /* - Delete points - */ - rpc Delete (DeletePoints) returns (PointsOperationResponse) {} - /* - Retrieve points - */ - rpc Get (GetPoints) returns (GetResponse) {} - /* - Update named vectors for point - */ - rpc UpdateVectors (UpdatePointVectors) returns (PointsOperationResponse) {} - /* - Delete named vectors for points - */ - rpc DeleteVectors (DeletePointVectors) returns (PointsOperationResponse) {} - /* - Set payload for points - */ - rpc SetPayload (SetPayloadPoints) returns (PointsOperationResponse) {} - /* - Overwrite payload for points - */ - rpc OverwritePayload (SetPayloadPoints) returns (PointsOperationResponse) {} - /* - Delete specified key payload for points - */ - rpc DeletePayload (DeletePayloadPoints) returns (PointsOperationResponse) {} - /* - Remove all payload for specified points - */ - rpc ClearPayload (ClearPayloadPoints) returns (PointsOperationResponse) {} - /* - Create index for field in collection - */ - rpc CreateFieldIndex (CreateFieldIndexCollection) returns (PointsOperationResponse) {} - /* - Delete field index for collection - */ - rpc DeleteFieldIndex (DeleteFieldIndexCollection) returns (PointsOperationResponse) {} - /* - Retrieve closest points based on vector similarity and given filtering conditions - */ - rpc Search (SearchPoints) returns (SearchResponse) {} - /* - Retrieve closest points based on vector similarity and given filtering conditions - */ - rpc SearchBatch (SearchBatchPoints) returns (SearchBatchResponse) {} - /* - Retrieve closest points based on vector similarity and given filtering conditions, grouped by a given field - */ - rpc SearchGroups (SearchPointGroups) returns (SearchGroupsResponse) {} - /* - Iterate over all or filtered points - */ - rpc Scroll (ScrollPoints) returns (ScrollResponse) {} - /* - Look for the points which are closer to stored positive examples and at the same time further to negative examples. - */ - rpc Recommend (RecommendPoints) returns (RecommendResponse) {} - /* - Look for the points which are closer to stored positive examples and at the same time further to negative examples. - */ - rpc RecommendBatch (RecommendBatchPoints) returns (RecommendBatchResponse) {} - /* - Look for the points which are closer to stored positive examples and at the same time further to negative examples, grouped by a given field - */ - rpc RecommendGroups (RecommendPointGroups) returns (RecommendGroupsResponse) {} - /* - Count points in collection with given filtering conditions - */ - rpc Count (CountPoints) returns (CountResponse) {} - - /* - Perform multiple update operations in one request - */ - rpc UpdateBatch (UpdateBatchPoints) returns (UpdateBatchResponse) {} -} diff --git a/src/main/proto/qdrant.proto b/src/main/proto/qdrant.proto deleted file mode 100644 index 97b525e7..00000000 --- a/src/main/proto/qdrant.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -import "collections_service.proto"; -import "points_service.proto"; -import "snapshots_service.proto"; - -package qdrant; - -option java_package = "io.qdrant.client.grpc"; - -service Qdrant { - rpc HealthCheck (HealthCheckRequest) returns (HealthCheckReply) {} -} - -message HealthCheckRequest {} - -message HealthCheckReply { - string title = 1; - string version = 2; -} diff --git a/src/main/proto/snapshots_service.proto b/src/main/proto/snapshots_service.proto deleted file mode 100644 index e858a333..00000000 --- a/src/main/proto/snapshots_service.proto +++ /dev/null @@ -1,77 +0,0 @@ -syntax = "proto3"; - -package qdrant; - -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option java_package = "io.qdrant.client.grpc"; - -service Snapshots { - /* - Create collection snapshot - */ - rpc Create (CreateSnapshotRequest) returns (CreateSnapshotResponse) {} - /* - List collection snapshots - */ - rpc List (ListSnapshotsRequest) returns (ListSnapshotsResponse) {} - /* - Delete collection snapshots - */ - rpc Delete (DeleteSnapshotRequest) returns (DeleteSnapshotResponse) {} - /* - Create full storage snapshot - */ - rpc CreateFull (CreateFullSnapshotRequest) returns (CreateSnapshotResponse) {} - /* - List full storage snapshots - */ - rpc ListFull (ListFullSnapshotsRequest) returns (ListSnapshotsResponse) {} - /* - List full storage snapshots - */ - rpc DeleteFull (DeleteFullSnapshotRequest) returns (DeleteSnapshotResponse) {} - -} - -message CreateFullSnapshotRequest {} - -message ListFullSnapshotsRequest {} - -message DeleteFullSnapshotRequest { - string snapshot_name = 1; // Name of the full snapshot -} - -message CreateSnapshotRequest { - string collection_name = 1; // Name of the collection -} - -message ListSnapshotsRequest { - string collection_name = 1; // Name of the collection -} - -message DeleteSnapshotRequest { - string collection_name = 1; // Name of the collection - string snapshot_name = 2; // Name of the collection snapshot -} - -message SnapshotDescription { - string name = 1; // Name of the snapshot - google.protobuf.Timestamp creation_time = 2; // Creation time of the snapshot - int64 size = 3; // Size of the snapshot in bytes -} - -message CreateSnapshotResponse { - SnapshotDescription snapshot_description = 1; - double time = 2; // Time spent to process -} - -message ListSnapshotsResponse { - repeated SnapshotDescription snapshot_descriptions = 1; - double time = 2; // Time spent to process -} - -message DeleteSnapshotResponse { - double time = 1; // Time spent to process -} diff --git a/src/test/java/io/qdrant/client/ApiKeyTest.java b/src/test/java/io/qdrant/client/ApiKeyTest.java new file mode 100644 index 00000000..2c2f26c3 --- /dev/null +++ b/src/test/java/io/qdrant/client/ApiKeyTest.java @@ -0,0 +1,66 @@ +package io.qdrant.client; + +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import io.qdrant.client.container.QdrantContainer; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import static io.qdrant.client.grpc.QdrantOuterClass.HealthCheckReply; +import static io.qdrant.client.grpc.QdrantOuterClass.HealthCheckRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@Testcontainers +public class ApiKeyTest { + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer().withApiKey("password!"); + private ManagedChannel channel; + + @BeforeEach + public void setup() { + channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + } + + @AfterEach + public void teardown() throws InterruptedException { + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + + @Test + public void client_with_api_key_can_connect() throws ExecutionException, InterruptedException { + HealthCheckReply healthCheckReply; + try (QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).withApiKey("password!").build()) { + healthCheckReply = grpcClient.qdrant().healthCheck(HealthCheckRequest.getDefaultInstance()).get(); + } + + assertNotNull(healthCheckReply.getTitle()); + assertNotNull(healthCheckReply.getVersion()); + } + + @Test + public void client_without_api_key_cannot_connect() { + try (QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).build()) { + ExecutionException executionException = assertThrows( + ExecutionException.class, + () -> grpcClient.qdrant().healthCheck(HealthCheckRequest.getDefaultInstance()).get()); + Throwable cause = executionException.getCause(); + assertEquals(StatusRuntimeException.class, cause.getClass()); + StatusRuntimeException statusRuntimeException = (StatusRuntimeException) cause; + assertEquals(Status.Code.PERMISSION_DENIED, statusRuntimeException.getStatus().getCode()); + } + } +} diff --git a/src/test/java/io/qdrant/client/CollectionsTest.java b/src/test/java/io/qdrant/client/CollectionsTest.java new file mode 100644 index 00000000..26779d22 --- /dev/null +++ b/src/test/java/io/qdrant/client/CollectionsTest.java @@ -0,0 +1,254 @@ +package io.qdrant.client; + +import io.qdrant.client.grpc.Collections; +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import io.qdrant.client.container.QdrantContainer; + +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import static io.qdrant.client.grpc.Collections.AliasDescription; +import static io.qdrant.client.grpc.Collections.CollectionInfo; +import static io.qdrant.client.grpc.Collections.CollectionStatus; +import static io.qdrant.client.grpc.Collections.CreateCollection; +import static io.qdrant.client.grpc.Collections.Distance; +import static io.qdrant.client.grpc.Collections.VectorParams; +import static io.qdrant.client.grpc.Collections.VectorsConfig; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@Testcontainers +class CollectionsTest { + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(); + private QdrantClient client; + private ManagedChannel channel; + private String testName; + + private static CreateCollection getCreateCollection(String collectionName) { + return CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParams(VectorParams.newBuilder() + .setDistance(Distance.Cosine) + .setSize(4) + .build()) + .build()) + .build(); + } + + @BeforeEach + public void setup(TestInfo testInfo) { + testName = testInfo.getDisplayName().replace("()", ""); + channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).build(); + client = new QdrantClient(grpcClient); + } + + @AfterEach + public void teardown() throws Exception { + List collectionNames = client.listCollectionsAsync().get(); + for (String collectionName : collectionNames) { + client.deleteCollectionAsync(collectionName).get(); + } + client.close(); + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + + @Test + void createCollection() throws ExecutionException, InterruptedException { + client.createCollectionAsync( + testName, + VectorParams.newBuilder() + .setDistance(Distance.Cosine) + .setSize(4) + .build()).get(); + + List collections = client.listCollectionsAsync().get(); + assertTrue(collections.contains(testName)); + } + + @Test + void createCollection_for_existing_collection() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + + ExecutionException exception = assertThrows(ExecutionException.class, () -> + client.createCollectionAsync(createCollection).get()); + assertEquals(StatusRuntimeException.class, exception.getCause().getClass()); + } + + @Test + void createCollection_with_no_collection_name() { + CreateCollection createCollection = CreateCollection.newBuilder() + .setVectorsConfig(VectorsConfig.newBuilder() + .setParams(VectorParams.newBuilder() + .setDistance(Distance.Cosine) + .setSize(4) + .build()) + .build()) + .build(); + + assertThrows( + IllegalArgumentException.class, + () -> client.createCollectionAsync(createCollection).get()); + } + + @Test + public void recreateCollection() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.recreateCollectionAsync(createCollection).get(); + + List collections = client.listCollectionsAsync().get(); + assertTrue(collections.contains(testName)); + } + + @Test + public void updateCollection() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.updateCollectionAsync(Collections.UpdateCollection.newBuilder() + .setCollectionName(testName) + .setVectorsConfig(Collections.VectorsConfigDiff.newBuilder() + .setParams(Collections.VectorParamsDiff.newBuilder() + .setOnDisk(false) + .build()) + .build()) + .build()).get(); + } + + @Test + public void updateCollection_with_no_changes() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.updateCollectionAsync(Collections.UpdateCollection.newBuilder() + .setCollectionName(testName) + .build()).get(); + } + + @Test + public void deleteCollection() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.deleteCollectionAsync(testName).get(); + + List collections = client.listCollectionsAsync().get(); + assertTrue(collections.isEmpty()); + } + + @Test + public void deleteCollection_with_missing_collection() { + ExecutionException exception = assertThrows(ExecutionException.class, () -> client.deleteCollectionAsync(testName).get()); + Throwable cause = exception.getCause(); + assertEquals(QdrantException.class, cause.getClass()); + } + + @Test + public void getCollectionInfo() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + CollectionInfo collectionInfo = client.getCollectionInfoAsync(testName).get(); + assertEquals(CollectionStatus.Green, collectionInfo.getStatus()); + } + + @Test + public void getCollectionInfo_with_missing_collection() { + ExecutionException exception = assertThrows(ExecutionException.class, () -> + client.getCollectionInfoAsync(testName).get()); + Throwable cause = exception.getCause(); + assertEquals(StatusRuntimeException.class, cause.getClass()); + StatusRuntimeException underlyingException = (StatusRuntimeException) cause; + assertEquals(Status.Code.NOT_FOUND, underlyingException.getStatus().getCode()); + } + + @Test + public void createAlias() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.createAliasAsync("alias_1", testName).get(); + } + + @Test + public void listAliases() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.createAliasAsync("alias_1", testName).get(); + client.createAliasAsync("alias_2", testName).get(); + + List aliasDescriptions = client.listAliasesAsync().get(); + + List sorted = aliasDescriptions.stream() + .sorted(Comparator.comparing(AliasDescription::getAliasName)) + .collect(Collectors.toList()); + + assertEquals(2, sorted.size()); + assertEquals("alias_1", sorted.get(0).getAliasName()); + assertEquals(testName, sorted.get(0).getCollectionName()); + assertEquals("alias_2", sorted.get(1).getAliasName()); + assertEquals(testName, sorted.get(1).getCollectionName()); + } + + @Test + public void listCollectionAliases() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.createAliasAsync("alias_1", testName).get(); + client.createAliasAsync("alias_2", testName).get(); + + List aliases = client.listCollectionAliasesAsync(testName).get(); + + List sorted = aliases.stream() + .sorted() + .collect(Collectors.toList()); + + assertEquals(2, sorted.size()); + assertEquals("alias_1", sorted.get(0)); + assertEquals("alias_2", sorted.get(1)); + } + + @Test + public void renameAlias() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.createAliasAsync("alias_1", testName).get(); + client.renameAliasAsync("alias_1", "alias_2").get(); + + List aliases = client.listCollectionAliasesAsync(testName).get(); + + List sorted = aliases.stream() + .sorted() + .collect(Collectors.toList()); + + assertEquals(1, sorted.size()); + assertEquals("alias_2", sorted.get(0)); + } + + @Test + public void deleteAlias() throws ExecutionException, InterruptedException { + CreateCollection createCollection = getCreateCollection(testName); + client.createCollectionAsync(createCollection).get(); + client.createAliasAsync("alias_1", testName).get(); + client.deleteAliasAsync("alias_1").get(); + + List aliases = client.listCollectionAliasesAsync(testName).get(); + assertTrue(aliases.isEmpty()); + } +} diff --git a/src/test/java/io/qdrant/client/HealthTest.java b/src/test/java/io/qdrant/client/HealthTest.java new file mode 100644 index 00000000..39afa29e --- /dev/null +++ b/src/test/java/io/qdrant/client/HealthTest.java @@ -0,0 +1,48 @@ +package io.qdrant.client; + +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import io.qdrant.client.container.QdrantContainer; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import static io.qdrant.client.grpc.QdrantOuterClass.HealthCheckReply; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Testcontainers +class HealthTest { + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(); + private QdrantClient client; + private ManagedChannel channel; + + @BeforeEach + public void setup() { + channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).build(); + client = new QdrantClient(grpcClient); + } + + @AfterEach + public void teardown() throws Exception { + client.close(); + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + + @Test + public void healthCheck() throws ExecutionException, InterruptedException { + HealthCheckReply healthCheckReply = client.healthCheckAsync().get(); + assertNotNull(healthCheckReply.getTitle()); + assertNotNull(healthCheckReply.getVersion()); + } +} diff --git a/src/test/java/io/qdrant/client/PointsTest.java b/src/test/java/io/qdrant/client/PointsTest.java new file mode 100644 index 00000000..82c30c5d --- /dev/null +++ b/src/test/java/io/qdrant/client/PointsTest.java @@ -0,0 +1,532 @@ +package io.qdrant.client; + +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.shaded.com.google.common.collect.ImmutableList; +import org.testcontainers.shaded.com.google.common.collect.ImmutableMap; +import org.testcontainers.shaded.com.google.common.collect.ImmutableSet; +import io.qdrant.client.container.QdrantContainer; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import static io.qdrant.client.grpc.Collections.CollectionInfo; +import static io.qdrant.client.grpc.Collections.CreateCollection; +import static io.qdrant.client.grpc.Collections.Distance; +import static io.qdrant.client.grpc.Collections.PayloadSchemaType; +import static io.qdrant.client.grpc.Collections.VectorParams; +import static io.qdrant.client.grpc.Collections.VectorsConfig; +import static io.qdrant.client.grpc.Points.BatchResult; +import static io.qdrant.client.grpc.Points.Filter; +import static io.qdrant.client.grpc.Points.PointGroup; +import static io.qdrant.client.grpc.Points.PointStruct; +import static io.qdrant.client.grpc.Points.RecommendPointGroups; +import static io.qdrant.client.grpc.Points.RecommendPoints; +import static io.qdrant.client.grpc.Points.RetrievedPoint; +import static io.qdrant.client.grpc.Points.ScoredPoint; +import static io.qdrant.client.grpc.Points.ScrollPoints; +import static io.qdrant.client.grpc.Points.ScrollResponse; +import static io.qdrant.client.grpc.Points.SearchPointGroups; +import static io.qdrant.client.grpc.Points.SearchPoints; +import static io.qdrant.client.grpc.Points.UpdateResult; +import static io.qdrant.client.grpc.Points.UpdateStatus; +import static io.qdrant.client.grpc.Points.Vectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static io.qdrant.client.ConditionFactory.hasId; +import static io.qdrant.client.ConditionFactory.matchKeyword; +import static io.qdrant.client.PointIdFactory.id; +import static io.qdrant.client.ValueFactory.value; +import static io.qdrant.client.VectorsFactory.vector; + +@Testcontainers +class PointsTest { + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(); + private QdrantClient client; + private ManagedChannel channel; + private String testName; + + @BeforeEach + public void setup(TestInfo testInfo) { + testName = testInfo.getDisplayName().replace("()", ""); + channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).build(); + client = new QdrantClient(grpcClient); + } + + @AfterEach + public void teardown() throws Exception { + List collectionNames = client.listCollectionsAsync().get(); + for (String collectionName : collectionNames) { + client.deleteCollectionAsync(collectionName).get(); + } + client.close(); + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + + @Test + public void retrieve() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.retrieveAsync( + testName, + id(9), + null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertEquals(ImmutableSet.of("foo", "bar"), point.getPayloadMap().keySet()); + assertEquals(value("goodbye"), point.getPayloadMap().get("foo")); + assertEquals(value(2), point.getPayloadMap().get("bar")); + assertEquals(Vectors.getDefaultInstance(), point.getVectors()); + } + + @Test + public void retrieve_with_vector_without_payload() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.retrieveAsync( + testName, + id(8), + false, + true, + null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(8), point.getId()); + assertTrue(point.getPayloadMap().isEmpty()); + assertEquals(Vectors.VectorsOptionsCase.VECTOR, point.getVectors().getVectorsOptionsCase()); + } + + @Test + public void setPayload() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.setPayloadAsync( + testName, + ImmutableMap.of("bar", value("some bar")), + id(9), + null, + null, + null).get(); + + List points = + client.retrieveAsync(testName, id(9), null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertEquals(ImmutableSet.of("foo", "bar"), point.getPayloadMap().keySet()); + assertEquals(value("some bar"), point.getPayloadMap().get("bar")); + assertEquals(value("goodbye"), point.getPayloadMap().get("foo")); + } + + @Test + public void overwritePayload() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.overwritePayloadAsync( + testName, + ImmutableMap.of("bar", value("some bar")), + id(9), + null, + null, + null).get(); + + List points = + client.retrieveAsync(testName, id(9), null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertEquals(ImmutableSet.of("bar"), point.getPayloadMap().keySet()); + assertEquals(value("some bar"), point.getPayloadMap().get("bar")); + } + + @Test + public void deletePayload() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.setPayloadAsync( + testName, + ImmutableMap.of("bar", value("some bar")), + id(9), + null, + null, + null).get(); + + client.deletePayloadAsync(testName, ImmutableList.of("foo"), id(9), null, null, null).get(); + + List points = + client.retrieveAsync(testName, id(9), null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertEquals(ImmutableSet.of("bar"), point.getPayloadMap().keySet()); + assertEquals(value("some bar"), point.getPayloadMap().get("bar")); + } + + @Test + public void clearPayload() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.clearPayloadAsync(testName, id(9), true, null, null).get(); + + List points = + client.retrieveAsync(testName, id(9), null).get(); + + assertEquals(1, points.size()); + RetrievedPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertTrue(point.getPayloadMap().isEmpty()); + } + + @Test + public void createFieldIndex() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + UpdateResult result = client.createPayloadIndexAsync( + testName, + "foo", + PayloadSchemaType.Keyword, + null, + null, + null, + null).get(); + + assertEquals(UpdateStatus.Completed, result.getStatus()); + + result = client.createPayloadIndexAsync( + testName, + "bar", + PayloadSchemaType.Integer, + null, + null, + null, + null).get(); + + assertEquals(UpdateStatus.Completed, result.getStatus()); + + CollectionInfo collectionInfo = client.getCollectionInfoAsync(testName).get(); + assertEquals(ImmutableSet.of("foo", "bar"), collectionInfo.getPayloadSchemaMap().keySet()); + assertEquals(PayloadSchemaType.Keyword, collectionInfo.getPayloadSchemaMap().get("foo").getDataType()); + assertEquals(PayloadSchemaType.Integer, collectionInfo.getPayloadSchemaMap().get("bar").getDataType()); + } + + @Test + public void deleteFieldIndex() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + UpdateResult result = client.createPayloadIndexAsync( + testName, + "foo", + PayloadSchemaType.Keyword, + null, + null, + null, + null).get(); + assertEquals(UpdateStatus.Completed, result.getStatus()); + + result = client.deletePayloadIndexAsync( + testName, + "foo", + null, + null, + null).get(); + assertEquals(UpdateStatus.Completed, result.getStatus()); + } + + @Test + public void search() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.searchAsync( + SearchPoints.newBuilder() + .setCollectionName(testName) + .setWithPayload(WithPayloadSelectorFactory.enable(true)) + .addAllVector(ImmutableList.of(10.4f, 11.4f)) + .setLimit(1) + .build()).get(); + + assertEquals(1, points.size()); + ScoredPoint point = points.get(0); + assertEquals(id(9), point.getId()); + assertEquals(ImmutableSet.of("foo", "bar"), point.getPayloadMap().keySet()); + assertEquals(value("goodbye"), point.getPayloadMap().get("foo")); + assertEquals(value(2), point.getPayloadMap().get("bar")); + assertFalse(point.getVectors().hasVector()); + } + + @Test + public void searchBatch() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List batchResults = client.searchBatchAsync(testName, + ImmutableList.of( + SearchPoints.newBuilder() + .addAllVector(ImmutableList.of(10.4f, 11.4f)) + .setLimit(1) + .build(), + SearchPoints.newBuilder() + .addAllVector(ImmutableList.of(3.4f, 4.4f)) + .setLimit(1) + .build() + ), null).get(); + + assertEquals(2, batchResults.size()); + BatchResult result = batchResults.get(0); + assertEquals(1, result.getResultCount()); + assertEquals(id(9), result.getResult(0).getId()); + result = batchResults.get(1); + assertEquals(1, result.getResultCount()); + assertEquals(id(8), result.getResult(0).getId()); + } + + @Test + public void searchGroups() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.upsertAsync( + testName, + ImmutableList.of( + PointStruct.newBuilder() + .setId(id(10)) + .setVectors(VectorsFactory.vector(30f, 31f)) + .putAllPayload(ImmutableMap.of("foo", value("hello"))) + .build() + ) + ).get(); + + List groups = client.searchGroupsAsync(SearchPointGroups.newBuilder() + .setCollectionName(testName) + .addAllVector(ImmutableList.of(10.4f, 11.4f)) + .setGroupBy("foo") + .setGroupSize(2) + .setLimit(10) + .build() + ).get(); + + assertEquals(2, groups.size()); + assertEquals(1, groups.stream().filter(g -> g.getHitsCount() == 2).count()); + assertEquals(1, groups.stream().filter(g -> g.getHitsCount() == 1).count()); + } + + @Test + public void scroll() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + ScrollResponse scrollResponse = client.scrollAsync(ScrollPoints.newBuilder() + .setCollectionName(testName) + .setLimit(1) + .build() + ).get(); + + assertEquals(1, scrollResponse.getResultCount()); + assertTrue(scrollResponse.hasNextPageOffset()); + + scrollResponse = client.scrollAsync(ScrollPoints.newBuilder() + .setCollectionName(testName) + .setLimit(1) + .setOffset(scrollResponse.getNextPageOffset()) + .build() + ).get(); + + assertEquals(1, scrollResponse.getResultCount()); + assertFalse(scrollResponse.hasNextPageOffset()); + } + + @Test + public void recommend() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.recommendAsync(RecommendPoints.newBuilder() + .setCollectionName(testName) + .addPositive(id(8)) + .setLimit(1) + .build() + ).get(); + + assertEquals(1, points.size()); + assertEquals(id(9), points.get(0).getId()); + } + + @Test + public void recommendBatch() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List batchResults = client.recommendBatchAsync(testName, + ImmutableList.of( + RecommendPoints.newBuilder() + .setCollectionName(testName) + .addPositive(id(8)) + .setLimit(1) + .build(), + RecommendPoints.newBuilder() + .setCollectionName(testName) + .addPositive(id(9)) + .setLimit(1) + .build() + ), + null + ).get(); + + assertEquals(2, batchResults.size()); + BatchResult result = batchResults.get(0); + assertEquals(1, result.getResultCount()); + assertEquals(id(9), result.getResult(0).getId()); + result = batchResults.get(1); + assertEquals(1, result.getResultCount()); + assertEquals(id(8), result.getResult(0).getId()); + } + + @Test + public void recommendGroups() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + client.upsertAsync( + testName, + ImmutableList.of( + PointStruct.newBuilder() + .setId(id(10)) + .setVectors(VectorsFactory.vector(30f, 31f)) + .putAllPayload(ImmutableMap.of("foo", value("hello"))) + .build() + ) + ).get(); + + List groups = client.recommendGroupsAsync(RecommendPointGroups.newBuilder() + .setCollectionName(testName) + .setGroupBy("foo") + .addPositive(id(9)) + .setGroupSize(2) + .setLimit(10) + .build() + ).get(); + + assertEquals(1, groups.size()); + assertEquals(2, groups.get(0).getHitsCount()); + } + + @Test + public void count() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + Long count = client.countAsync(testName).get(); + assertEquals(2, count); + } + + @Test + public void count_with_filter() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + Long count = client.countAsync( + testName, + Filter.newBuilder() + .addMust(hasId(id(9))) + .addMust(matchKeyword("foo", "goodbye")) + .build(), + null + ).get(); + assertEquals(1, count); + } + + @Test + public void delete_by_id() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.retrieveAsync( + testName, + id(8), + false, + false, + null).get(); + + assertEquals(1, points.size()); + + client.deleteAsync(testName, ImmutableList.of(id(8))).get(); + + points = client.retrieveAsync( + testName, + id(8), + false, + false, + null).get(); + + assertEquals(0, points.size()); + } + + @Test + public void delete_by_filter() throws ExecutionException, InterruptedException { + createAndSeedCollection(testName); + + List points = client.retrieveAsync( + testName, + id(8), + false, + false, + null).get(); + + assertEquals(1, points.size()); + + client.deleteAsync( + testName, + Filter.newBuilder().addMust(matchKeyword("foo", "hello")).build()).get(); + + points = client.retrieveAsync( + testName, + id(8), + false, + false, + null).get(); + + assertEquals(0, points.size()); + } + + private void createAndSeedCollection(String collectionName) throws ExecutionException, InterruptedException { + CreateCollection request = CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(VectorsConfig.newBuilder() + .setParams(VectorParams.newBuilder() + .setDistance(Distance.Cosine) + .setSize(2) + .build()) + .build()) + .build(); + + client.createCollectionAsync(request).get(); + + UpdateResult result = client.upsertAsync(collectionName, ImmutableList.of( + PointStruct.newBuilder() + .setId(id(8)) + .setVectors(VectorsFactory.vector(ImmutableList.of(3.5f, 4.5f))) + .putAllPayload(ImmutableMap.of( + "foo", value("hello"), + "bar", value(1) + )) + .build(), + PointStruct.newBuilder() + .setId(id(9)) + .setVectors(VectorsFactory.vector(ImmutableList.of(10.5f, 11.5f))) + .putAllPayload(ImmutableMap.of( + "foo", value("goodbye"), + "bar", value(2) + )) + .build() + )).get(); + assertEquals(UpdateStatus.Completed, result.getStatus()); + } +} diff --git a/src/test/java/io/qdrant/client/QdrantClientCollectionTest.java b/src/test/java/io/qdrant/client/QdrantClientCollectionTest.java deleted file mode 100644 index af7e9996..00000000 --- a/src/test/java/io/qdrant/client/QdrantClientCollectionTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package io.qdrant.client; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import io.grpc.StatusRuntimeException; -import io.qdrant.client.grpc.Collections; -import io.qdrant.client.grpc.Collections.Distance; -import java.util.UUID; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class QdrantClientCollectionTest { - - private static QdrantClient qdrantClient; - - @BeforeAll - static void setUp() throws Exception { - String qdrantUrl = System.getenv("QDRANT_URL"); - String apiKey = System.getenv("QDRANT_API_KEY"); - - if (qdrantUrl == null) { - qdrantUrl = "http://localhost:6334"; - } - - if (apiKey == null) { - qdrantClient = new QdrantClient(qdrantUrl); - } else { - qdrantClient = new QdrantClient(qdrantUrl, apiKey); - } - } - - @Test - void testAliasOperations() { - String collectionName = UUID.randomUUID().toString(); - String aliasName = UUID.randomUUID().toString(); - - assertThrows( - StatusRuntimeException.class, - () -> { - // This should fail as collection does not exist - qdrantClient.createAlias(collectionName, aliasName); - }); - - qdrantClient.createCollection(collectionName, 6, Distance.Euclid); - assertDoesNotThrow( - () -> { - Collections.CollectionOperationResponse response = - qdrantClient.createAlias(collectionName, aliasName); - assertTrue(response.getResult()); - }); - - Collections.ListAliasesResponse response = qdrantClient.listAliases(); - assertTrue(response.getAliasesCount() == 1); - Collections.AliasDescription alias = response.getAliasesList().get(0); - assertTrue(alias.getCollectionName().equals(collectionName)); - assertTrue(alias.getAliasName().equals(aliasName)); - - String newAliasName = UUID.randomUUID().toString(); - qdrantClient.renameAlias(aliasName, newAliasName); - response = qdrantClient.listAliases(); - assertTrue(response.getAliasesCount() == 1); - - alias = response.getAliasesList().get(0); - assertTrue(alias.getCollectionName().equals(collectionName)); - assertTrue(alias.getAliasName().equals(newAliasName)); - - qdrantClient.deleteAlias(newAliasName); - response = qdrantClient.listAliases(); - } - - @Test - void testListCollections() { - assertDoesNotThrow( - () -> { - Collections.ListCollectionsResponse response = qdrantClient.listCollections(); - assertTrue(response.getCollectionsCount() >= 0); - }); - } - - @Test - void testHasCollection() { - String collectionName = UUID.randomUUID().toString(); - boolean exists = qdrantClient.hasCollection(collectionName); - assertFalse(exists); - - qdrantClient.createCollection(collectionName, 6, Distance.Euclid); - - exists = qdrantClient.hasCollection(collectionName); - assertTrue(exists); - } - - @Test - void testCollectionConfigOperations() { - long vectorSize = 128; - String collectionName = UUID.randomUUID().toString(); - Collections.Distance distance = Collections.Distance.Cosine; - - Collections.VectorParams.Builder params = - Collections.VectorParams.newBuilder().setDistance(distance).setSize(vectorSize); - - Collections.VectorsConfig config = - Collections.VectorsConfig.newBuilder().setParams(params).build(); - - Collections.HnswConfigDiff hnsw = - Collections.HnswConfigDiff.newBuilder().setM(16).setEfConstruct(200).build(); - - Collections.CreateCollection details = - Collections.CreateCollection.newBuilder() - .setVectorsConfig(config) - .setHnswConfig(hnsw) - .setCollectionName(collectionName) - .build(); - - Collections.CollectionOperationResponse response = qdrantClient.createCollection(details); - assertTrue(response.getResult()); - - Collections.GetCollectionInfoResponse info = qdrantClient.getCollectionInfo(collectionName); - assertTrue(info.getResult().getConfig().getHnswConfig().getM() == 16); - - Collections.UpdateCollection updateCollection = - Collections.UpdateCollection.newBuilder() - .setCollectionName(collectionName) - .setHnswConfig(Collections.HnswConfigDiff.newBuilder().setM(32).build()) - .build(); - qdrantClient.updateCollection(updateCollection); - - info = qdrantClient.getCollectionInfo(collectionName); - assertTrue(info.getResult().getConfig().getHnswConfig().getM() == 32); - } - - @Test - void testRecreateCollection() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, 6, Distance.Euclid); - assertDoesNotThrow( - () -> { - qdrantClient.recreateCollection(collectionName, 12, Distance.Dot); - }); - } - - @Test - void testDeleteCollection() { - String collectionName = UUID.randomUUID().toString(); - - Collections.CollectionOperationResponse response = - qdrantClient.deleteCollection(collectionName); - assertFalse(response.getResult()); - - qdrantClient.createCollection(collectionName, 6, Distance.Euclid); - - response = qdrantClient.deleteCollection(collectionName); - assertTrue(response.getResult()); - } -} diff --git a/src/test/java/io/qdrant/client/QdrantClientPointsTest.java b/src/test/java/io/qdrant/client/QdrantClientPointsTest.java deleted file mode 100644 index 410b21db..00000000 --- a/src/test/java/io/qdrant/client/QdrantClientPointsTest.java +++ /dev/null @@ -1,264 +0,0 @@ -package io.qdrant.client; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import io.qdrant.client.grpc.Collections.Distance; -import io.qdrant.client.grpc.JsonWithInt.Value; -import io.qdrant.client.grpc.Points; -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.PointStruct; -import io.qdrant.client.grpc.Points.SearchPoints; -import io.qdrant.client.grpc.Points.SearchResponse; -import io.qdrant.client.utils.FilterUtil; -import io.qdrant.client.utils.PayloadUtil; -import io.qdrant.client.utils.PointUtil; -import io.qdrant.client.utils.SelectorUtil; -import io.qdrant.client.utils.VectorUtil; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class QdrantClientPointsTest { - - private static final int EMBEDDINGS_SIZE = 768; - private static QdrantClient qdrantClient; - - @BeforeAll - static void setUp() throws Exception { - String qdrantUrl = System.getenv("QDRANT_URL"); - String apiKey = System.getenv("QDRANT_API_KEY"); - - if (qdrantUrl == null) { - qdrantUrl = "http://localhost:6334"; - } - - if (apiKey == null) { - qdrantClient = new QdrantClient(qdrantUrl); - } else { - qdrantClient = new QdrantClient(qdrantUrl, apiKey); - } - } - - @Test - void testPointsWithPayloadFilters() { - String collectionName = UUID.randomUUID().toString(); - - UUID pointID = UUID.randomUUID(); - - qdrantClient.createCollection(collectionName, EMBEDDINGS_SIZE, Distance.Cosine); - - PointId[] pointIds = new PointId[] {PointUtil.pointId(pointID)}; - - Points.GetResponse response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - - assertEquals(0, response.getResultCount()); - - Map data = new HashMap<>(); - data.put("name", "Anush"); - data.put("age", 32); - - Map nestedData = new HashMap<>(); - nestedData.put("color", "Blue"); - nestedData.put("movie", "Man Of Steel"); - - data.put("favourites", nestedData); - - PointStruct point = - PointUtil.point( - pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), PayloadUtil.toPayload(data)); - - List points = Arrays.asList(point); - qdrantClient.upsertPointsBlocking(collectionName, points, null); - response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - assertEquals(1, response.getResultCount()); - - Filter filter = - FilterUtil.must( - FilterUtil.fieldCondition("age", FilterUtil.match(32)), - FilterUtil.fieldCondition("name", FilterUtil.match("Anush")), - FilterUtil.fieldCondition("favourites.color", FilterUtil.match("Blue")), - FilterUtil.fieldCondition("favourites.movie", FilterUtil.match("Man Of Steel"))); - qdrantClient.deletePointsBlocking(collectionName, SelectorUtil.filterSelector(filter), null); - - response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - - assertEquals(0, response.getResultCount()); - } - - @Test - void testUpsertPoints() { - String collectionName = UUID.randomUUID().toString(); - - UUID pointID = UUID.randomUUID(); - - qdrantClient.createCollection(collectionName, EMBEDDINGS_SIZE, Distance.Cosine); - - PointId[] pointIds = new PointId[] {PointUtil.pointId(pointID)}; - - Points.GetResponse response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - - assertEquals(0, response.getResultCount()); - - PointStruct point = PointUtil.point(pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), null); - List points = Arrays.asList(point); - qdrantClient.upsertPointsBlocking(collectionName, points, null); - response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - assertEquals(1, response.getResultCount()); - - qdrantClient.deletePointsBlocking(collectionName, SelectorUtil.idsSelector(pointIds), null); - - response = - qdrantClient.getPoints( - collectionName, - Arrays.asList(pointIds), - SelectorUtil.withVectors(), - SelectorUtil.withPayload(), - null); - - assertEquals(0, response.getResultCount()); - } - - @Test - void testUpsertPointsBatch() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, EMBEDDINGS_SIZE, Distance.Cosine); - - List points = new ArrayList<>(); - - // Upsert 1000 points with batching - for (int i = 0; i < 1000; i++) { - UUID pointID = UUID.randomUUID(); - PointStruct point = PointUtil.point(pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), null); - points.add(point); - } - - assertDoesNotThrow( - () -> { - qdrantClient.upsertPointsBatchBlocking(collectionName, points, null, 100); - }); - } - - @Test - void testSearchPoints() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, EMBEDDINGS_SIZE, Distance.Cosine); - - List points = new ArrayList<>(); - - // Upsert 100 points - for (int i = 0; i < 100; i++) { - UUID pointID = UUID.randomUUID(); - PointStruct point = PointUtil.point(pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), null); - points.add(point); - } - - assertDoesNotThrow( - () -> { - qdrantClient.upsertPointsBlocking(collectionName, points, null); - }); - - SearchPoints request = - SearchPoints.newBuilder() - .setCollectionName(collectionName) - .addAllVector(VectorUtil.dummyEmbeddings(EMBEDDINGS_SIZE)) - .setWithPayload(SelectorUtil.withPayload()) - .setLimit(100) - .build(); - - SearchResponse result = qdrantClient.searchPoints(request); - - assertEquals(result.getResultList().size(), 100); - } - - @Test - void testSetPayloadWithScroll() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, EMBEDDINGS_SIZE, Distance.Cosine); - - List points = new ArrayList<>(); - - // Upsert 100 points - for (int i = 0; i < 100; i++) { - UUID pointID = UUID.randomUUID(); - PointStruct point = PointUtil.point(pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), null); - points.add(point); - } - - assertDoesNotThrow( - () -> { - qdrantClient.upsertPointsBlocking(collectionName, points, null); - }); - - Map data = new HashMap<>(); - data.put("name", "Anush"); - data.put("age", 32); - - Map nestedData = new HashMap<>(); - nestedData.put("color", "Blue"); - nestedData.put("movie", "Man of Steel"); - - data.put("favourites", nestedData); - - Map payload = PayloadUtil.toPayload(data); - - qdrantClient.setPayloadBlocking( - collectionName, SelectorUtil.filterSelector(FilterUtil.must()), payload, null); - - Points.ScrollPoints request = - Points.ScrollPoints.newBuilder() - .setCollectionName(collectionName) - .setWithPayload(SelectorUtil.withPayload()) - .setLimit(100) - .build(); - - Points.ScrollResponse response = qdrantClient.scroll(request); - - response - .getResultList() - .forEach( - (point) -> { - assertEquals(PayloadUtil.toMap(point.getPayloadMap()), data); - assertEquals(point.getPayloadMap(), PayloadUtil.toPayload(data)); - }); - } -} diff --git a/src/test/java/io/qdrant/client/QdrantClientServiceTest.java b/src/test/java/io/qdrant/client/QdrantClientServiceTest.java deleted file mode 100644 index 0fa4b037..00000000 --- a/src/test/java/io/qdrant/client/QdrantClientServiceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.qdrant.client; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.net.MalformedURLException; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class QdrantClientServiceTest { - - private static QdrantClient qdrantClient; - - @BeforeAll - static void setUp() throws Exception { - String qdrantUrl = System.getenv("QDRANT_URL"); - String apiKey = System.getenv("QDRANT_API_KEY"); - - if (qdrantUrl == null) { - qdrantUrl = "http://localhost:6334"; - } - - if (apiKey == null) { - qdrantClient = new QdrantClient(qdrantUrl); - } else { - qdrantClient = new QdrantClient(qdrantUrl, apiKey); - } - } - - @Test - void testInvalidProtocol() { - assertThrows(IllegalArgumentException.class, () -> new QdrantClient("ftp://localhost:6334")); - } - - @Test - void testMalformedUrl() { - assertThrows(MalformedURLException.class, () -> new QdrantClient("qdrant/qdrant:latest")); - } - - @Test - void testHealthCheck() { - assertEquals(qdrantClient.healthCheck().getTitle(), "qdrant - vector search engine"); - } -} diff --git a/src/test/java/io/qdrant/client/QdrantClientSnapshotsTest.java b/src/test/java/io/qdrant/client/QdrantClientSnapshotsTest.java deleted file mode 100644 index fca84a9e..00000000 --- a/src/test/java/io/qdrant/client/QdrantClientSnapshotsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package io.qdrant.client; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import io.qdrant.client.grpc.Collections.Distance; -import io.qdrant.client.grpc.SnapshotsService; -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.util.UUID; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class QdrantClientSnapshotsTest { - - private static QdrantClient qdrantClient; - - @BeforeAll - static void setUp() throws Exception { - String qdrantUrl = System.getenv("QDRANT_URL"); - String apiKey = System.getenv("QDRANT_API_KEY"); - - if (qdrantUrl == null) { - qdrantUrl = "http://localhost:6334"; - } - - if (apiKey == null) { - qdrantClient = new QdrantClient(qdrantUrl); - } else { - qdrantClient = new QdrantClient(qdrantUrl, apiKey); - } - } - - @Test - void testCollectionSnapshots() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, 768, Distance.Cosine); - - assertEquals( - qdrantClient.listSnapshots(collectionName).getSnapshotDescriptionsList().size(), 0); - - assertDoesNotThrow( - () -> { - SnapshotsService.CreateSnapshotResponse response = - qdrantClient.createSnapshot(collectionName); - String snapshotName = response.getSnapshotDescription().getName(); - - assertEquals( - qdrantClient.listSnapshots(collectionName).getSnapshotDescriptionsList().size(), 1); - - qdrantClient.deleteSnapshot(collectionName, snapshotName); - - assertEquals( - qdrantClient.listSnapshots(collectionName).getSnapshotDescriptionsList().size(), 0); - }); - } - - @Test - void testFullSnapshots() { - - assertEquals(qdrantClient.listFullSnapshots().getSnapshotDescriptionsList().size(), 0); - - assertDoesNotThrow( - () -> { - SnapshotsService.CreateSnapshotResponse response = qdrantClient.createFullSnapshot(); - String snapshotName = response.getSnapshotDescription().getName(); - - assertEquals(qdrantClient.listFullSnapshots().getSnapshotDescriptionsList().size(), 1); - - qdrantClient.deleteFullSnapshot(snapshotName); - - assertEquals(qdrantClient.listFullSnapshots().getSnapshotDescriptionsList().size(), 0); - }); - } - - @Test - void testDownloadSnapshot() { - String collectionName = UUID.randomUUID().toString(); - - qdrantClient.createCollection(collectionName, 768, Distance.Cosine); - - assertEquals( - qdrantClient.listSnapshots(collectionName).getSnapshotDescriptionsList().size(), 0); - - // Test with snapshot name - assertDoesNotThrow( - () -> { - SnapshotsService.CreateSnapshotResponse response = - qdrantClient.createSnapshot(collectionName); - String snapshotName = response.getSnapshotDescription().getName(); - - Path path = FileSystems.getDefault().getPath("./test.snapshot"); - qdrantClient.downloadSnapshot(path, collectionName, snapshotName, null); - }); - - // Test without snapshot name - assertDoesNotThrow( - () -> { - qdrantClient.createSnapshot(collectionName); - - Path path = FileSystems.getDefault().getPath("./test_2.snapshot"); - qdrantClient.downloadSnapshot(path, collectionName, null, null); - }); - } -} diff --git a/src/test/java/io/qdrant/client/QdrantGrpcClientTest.java b/src/test/java/io/qdrant/client/QdrantGrpcClientTest.java new file mode 100644 index 00000000..3eb8b39d --- /dev/null +++ b/src/test/java/io/qdrant/client/QdrantGrpcClientTest.java @@ -0,0 +1,47 @@ +package io.qdrant.client; + +import io.qdrant.client.grpc.QdrantOuterClass; +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import io.qdrant.client.container.QdrantContainer; + +import java.util.concurrent.ExecutionException; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Testcontainers +class QdrantGrpcClientTest { + + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(); + private QdrantGrpcClient client; + + @BeforeEach + public void setup() { + client = QdrantGrpcClient.newBuilder( + Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build()) + .build(); + } + + @AfterEach + public void teardown() { + client.close(); + } + + @Test + void healthCheck() throws ExecutionException, InterruptedException { + QdrantOuterClass.HealthCheckReply healthCheckReply = + client.qdrant().healthCheck(QdrantOuterClass.HealthCheckRequest.getDefaultInstance()).get(); + + assertNotNull(healthCheckReply.getTitle()); + assertNotNull(healthCheckReply.getVersion()); + } +} \ No newline at end of file diff --git a/src/test/java/io/qdrant/client/SnapshotsTest.java b/src/test/java/io/qdrant/client/SnapshotsTest.java new file mode 100644 index 00000000..d2366736 --- /dev/null +++ b/src/test/java/io/qdrant/client/SnapshotsTest.java @@ -0,0 +1,150 @@ +package io.qdrant.client; + +import io.qdrant.client.grpc.Collections; +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import io.qdrant.client.container.QdrantContainer; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import static io.qdrant.client.grpc.SnapshotsService.SnapshotDescription; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@Testcontainers +class SnapshotsTest { + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(); + private QdrantClient client; + private ManagedChannel channel; + private String testName; + + @BeforeEach + public void setup(TestInfo testInfo) { + testName = testInfo.getDisplayName().replace("()", ""); + channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel).build(); + client = new QdrantClient(grpcClient); + } + + @AfterEach + public void teardown() throws Exception { + List collectionNames = client.listCollectionsAsync().get(); + for (String collectionName : collectionNames) { + List snapshots = client.listSnapshotAsync(collectionName).get(); + for (SnapshotDescription snapshot : snapshots) { + client.deleteSnapshotAsync(collectionName, snapshot.getName()).get(); + } + client.deleteCollectionAsync(collectionName).get(); + } + + List snapshots = client.listFullSnapshotAsync().get(); + for (SnapshotDescription snapshot : snapshots) { + client.deleteFullSnapshotAsync(snapshot.getName()).get(); + } + + client.close(); + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + + @Test + public void createSnapshot() throws ExecutionException, InterruptedException { + createCollection(testName); + client.createSnapshotAsync(testName).get(); + } + + @Test + public void deleteSnapshot() throws ExecutionException, InterruptedException { + createCollection(testName); + SnapshotDescription snapshotDescription = client.createSnapshotAsync(testName).get(); + client.deleteSnapshotAsync(testName, snapshotDescription.getName()).get(); + } + + @Test + public void deleteSnapshot_with_missing_snapshot() { + ExecutionException exception = + assertThrows(ExecutionException.class, () -> client.deleteSnapshotAsync(testName, "snapshot_1").get()); + Throwable cause = exception.getCause(); + assertEquals(StatusRuntimeException.class, cause.getClass()); + StatusRuntimeException underlyingException = (StatusRuntimeException) cause; + assertEquals(Status.Code.NOT_FOUND, underlyingException.getStatus().getCode()); + } + + @Test + public void listSnapshots() throws ExecutionException, InterruptedException { + createCollection(testName); + client.createSnapshotAsync(testName).get(); + // snapshots are timestamped named to second precision. Wait more than 1 second to ensure we get 2 snapshots + Thread.sleep(2000); + client.createSnapshotAsync(testName).get(); + + List snapshotDescriptions = client.listSnapshotAsync(testName).get(); + assertEquals(2, snapshotDescriptions.size()); + } + + @Test + public void createFullSnapshot() throws ExecutionException, InterruptedException { + createCollection(testName); + createCollection(testName + "2"); + client.createFullSnapshotAsync().get(); + } + + @Test + public void deleteFullSnapshot() throws ExecutionException, InterruptedException { + createCollection(testName); + createCollection(testName + "2"); + SnapshotDescription snapshotDescription = client.createFullSnapshotAsync().get(); + client.deleteFullSnapshotAsync(snapshotDescription.getName()).get(); + } + + @Test + public void deleteFullSnapshot_with_missing_snapshot() { + ExecutionException exception = + assertThrows(ExecutionException.class, () -> client.deleteFullSnapshotAsync("snapshot_1").get()); + Throwable cause = exception.getCause(); + assertEquals(StatusRuntimeException.class, cause.getClass()); + StatusRuntimeException underlyingException = (StatusRuntimeException) cause; + assertEquals(Status.Code.NOT_FOUND, underlyingException.getStatus().getCode()); + } + + @Test + public void listFullSnapshots() throws ExecutionException, InterruptedException { + createCollection(testName); + createCollection(testName + 2); + client.createFullSnapshotAsync().get(); + // snapshots are timestamped named to second precision. Wait more than 1 second to ensure we get 2 snapshots + Thread.sleep(2000); + client.createFullSnapshotAsync().get(); + + List snapshotDescriptions = client.listFullSnapshotAsync().get(); + assertEquals(2, snapshotDescriptions.size()); + } + + private void createCollection(String collectionName) throws ExecutionException, InterruptedException { + Collections.CreateCollection request = Collections.CreateCollection.newBuilder() + .setCollectionName(collectionName) + .setVectorsConfig(Collections.VectorsConfig.newBuilder() + .setParams(Collections.VectorParams.newBuilder() + .setDistance(Collections.Distance.Cosine) + .setSize(4) + .build()) + .build()) + .build(); + + client.createCollectionAsync(request).get(); + } +} diff --git a/src/test/java/io/qdrant/client/container/QdrantContainer.java b/src/test/java/io/qdrant/client/container/QdrantContainer.java new file mode 100644 index 00000000..f6792fa1 --- /dev/null +++ b/src/test/java/io/qdrant/client/container/QdrantContainer.java @@ -0,0 +1,41 @@ +package io.qdrant.client.container; + +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; +import org.testcontainers.utility.DockerImageName; + +public class QdrantContainer extends GenericContainer { + + private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("qdrant/qdrant"); + private static final String DEFAULT_TAG = System.getProperty("qdrantVersion"); + private static final int GRPC_PORT = 6334; + private static final int HTTP_PORT = 6333; + + public QdrantContainer() { + this(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG)); + } + + public QdrantContainer(String dockerImageName) { + this(DockerImageName.parse(dockerImageName)); + } + + public QdrantContainer(final DockerImageName dockerImageName) { + super(dockerImageName); + + addExposedPorts(GRPC_PORT, HTTP_PORT); + + setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*Actix runtime found; starting in Actix runtime.*")); + } + + public QdrantContainer withApiKey(String apiKey) { + return withEnv("QDRANT__SERVICE__API_KEY", apiKey); + } + + public String getGrpcHostAddress() { + return getHost() + ":" + getMappedPort(GRPC_PORT); + } + + public String getHttpHostAddress() { + return getHost() + ":" + getMappedPort(HTTP_PORT); + } +} diff --git a/src/test/java/io/qdrant/client/package-info.java b/src/test/java/io/qdrant/client/package-info.java new file mode 100644 index 00000000..c79c961b --- /dev/null +++ b/src/test/java/io/qdrant/client/package-info.java @@ -0,0 +1,4 @@ +@ParametersAreNonnullByDefault +package io.qdrant.client; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/test/java/io/qdrant/client/utils/FilterUtilTest.java b/src/test/java/io/qdrant/client/utils/FilterUtilTest.java deleted file mode 100644 index d0ed7e46..00000000 --- a/src/test/java/io/qdrant/client/utils/FilterUtilTest.java +++ /dev/null @@ -1,312 +0,0 @@ -package io.qdrant.client.utils; - -import static org.junit.jupiter.api.Assertions.*; - -import io.qdrant.client.grpc.Points.Condition; -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.GeoBoundingBox; -import io.qdrant.client.grpc.Points.GeoLineString; -import io.qdrant.client.grpc.Points.GeoPoint; -import io.qdrant.client.grpc.Points.GeoPolygon; -import io.qdrant.client.grpc.Points.GeoRadius; -import io.qdrant.client.grpc.Points.Match; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.Range; -import io.qdrant.client.grpc.Points.ValuesCount; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.junit.jupiter.api.Test; - -class FilterUtilTest { - - @Test - void testFieldConditionForTextMatching() { - String key = "name"; - Match match = FilterUtil.match("Elon"); - Condition condition = FilterUtil.fieldCondition(key, match); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasMatch()); - assertEquals(match, condition.getField().getMatch()); - } - - @Test - void testFieldConditionForRangeMatching() { - String key = "age"; - Range range = FilterUtil.range(20, 50, 20, 50); - Condition condition = FilterUtil.fieldCondition(key, range); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasRange()); - assertEquals(range, condition.getField().getRange()); - } - - @Test - void testFieldConditionForGeoBoundingBoxMatching() { - String key = "location"; - GeoBoundingBox geoBoundingBox = - FilterUtil.geoBoundingBox(FilterUtil.geoPoint(10.0, 20.0), FilterUtil.geoPoint(30.0, 40.0)); - Condition condition = FilterUtil.fieldCondition(key, geoBoundingBox); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasGeoBoundingBox()); - assertEquals(geoBoundingBox, condition.getField().getGeoBoundingBox()); - } - - @Test - void testFieldConditionForGeoRadiusMatching() { - String key = "location"; - GeoRadius geoRadius = FilterUtil.geoRadius(FilterUtil.geoPoint(10.0, 20.0), 100.0f); - Condition condition = FilterUtil.fieldCondition(key, geoRadius); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasGeoRadius()); - assertEquals(geoRadius, condition.getField().getGeoRadius()); - } - - @Test - void testFieldConditionForValuesCountMatching() { - String key = "count"; - ValuesCount valuesCount = FilterUtil.valuesCount(0, 10, 0, 10); - Condition condition = FilterUtil.fieldCondition(key, valuesCount); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasValuesCount()); - assertEquals(valuesCount, condition.getField().getValuesCount()); - } - - @Test - void testFieldConditionForGeoPolygonMatching() { - String key = "area"; - GeoPolygon geoPolygon = - FilterUtil.geoPolygon( - GeoLineString.newBuilder() - .addPoints(FilterUtil.geoPoint(10.0, 20.0)) - .addPoints(FilterUtil.geoPoint(30.0, 40.0)) - .build(), - Collections.singletonList( - GeoLineString.newBuilder() - .addPoints(FilterUtil.geoPoint(15.0, 25.0)) - .addPoints(FilterUtil.geoPoint(35.0, 45.0)) - .build())); - Condition condition = FilterUtil.fieldCondition(key, geoPolygon); - - assertTrue(condition.hasField()); - assertEquals(key, condition.getField().getKey()); - assertTrue(condition.getField().hasGeoPolygon()); - assertEquals(geoPolygon, condition.getField().getGeoPolygon()); - } - - @Test - void testMatchForStringMatching() { - String text = "Elon"; - Match match = FilterUtil.match(text); - - assertTrue(match.hasKeyword()); - assertEquals(text, match.getKeyword()); - assertFalse(match.hasText()); - } - - @Test - void testMatchForStringMatchingWithSpace() { - String text = "Elon Musk"; - Match match = FilterUtil.match(text); - - assertTrue(match.hasText()); - assertEquals(text, match.getText()); - assertFalse(match.hasKeyword()); - } - - @Test - void testMatchForIntegerMatching() { - long value = 42; - Match match = FilterUtil.match(value); - - assertTrue(match.hasInteger()); - assertEquals(value, match.getInteger()); - } - - @Test - void testMatchForBooleanMatching() { - boolean value = true; - Match match = FilterUtil.match(value); - - assertTrue(match.hasBoolean()); - assertEquals(value, match.getBoolean()); - } - - @Test - void testMatchWithKeywords() { - List keywords = Arrays.asList("apple", "banana", "cherry"); - Match match = FilterUtil.matchWithKeywords(keywords); - - assertTrue(match.hasKeywords()); - assertEquals(keywords, match.getKeywords().getStringsList()); - } - - @Test - void testMatchWithIntegers() { - List integers = Arrays.asList(1L, 2L, 3L); - Match match = FilterUtil.matchWithIntegers(integers); - - assertTrue(match.hasIntegers()); - assertEquals(integers, match.getIntegers().getIntegersList()); - } - - @Test - void testGeoBoundingBox() { - GeoPoint topLeft = FilterUtil.geoPoint(10.0, 20.0); - GeoPoint bottomRight = FilterUtil.geoPoint(30.0, 40.0); - GeoBoundingBox geoBoundingBox = FilterUtil.geoBoundingBox(topLeft, bottomRight); - - assertEquals(topLeft, geoBoundingBox.getTopLeft()); - assertEquals(bottomRight, geoBoundingBox.getBottomRight()); - } - - @Test - void testGeoRadius() { - GeoPoint center = FilterUtil.geoPoint(10.0, 20.0); - float radius = 100.0f; - GeoRadius geoRadius = FilterUtil.geoRadius(center, radius); - - assertEquals(center, geoRadius.getCenter()); - assertEquals(radius, geoRadius.getRadius()); - } - - @Test - void testGeoPolygon() { - GeoLineString exterior = - GeoLineString.newBuilder() - .addPoints(FilterUtil.geoPoint(10.0, 20.0)) - .addPoints(FilterUtil.geoPoint(30.0, 40.0)) - .build(); - List interiors = - Collections.singletonList( - GeoLineString.newBuilder() - .addPoints(FilterUtil.geoPoint(15.0, 25.0)) - .addPoints(FilterUtil.geoPoint(35.0, 45.0)) - .build()); - GeoPolygon geoPolygon = FilterUtil.geoPolygon(exterior, interiors); - - assertEquals(exterior, geoPolygon.getExterior()); - assertEquals(interiors, geoPolygon.getInteriorsList()); - } - - @Test - void testRange() { - double lt = 10.0; - double gt = 20.0; - double gte = 15.0; - double lte = 25.0; - Range range = FilterUtil.range(lt, gt, gte, lte); - - assertEquals(lt, range.getLt()); - assertEquals(gt, range.getGt()); - assertEquals(gte, range.getGte()); - assertEquals(lte, range.getLte()); - } - - @Test - void testValuesCount() { - long lt = 0; - long gt = 10; - long gte = 0; - long lte = 5; - ValuesCount valuesCount = FilterUtil.valuesCount(lt, gt, gte, lte); - - assertEquals(lt, valuesCount.getLt()); - assertEquals(gt, valuesCount.getGt()); - assertEquals(gte, valuesCount.getGte()); - assertEquals(lte, valuesCount.getLte()); - } - - @Test - void testFilterCondition() { - Filter filter = Filter.newBuilder().build(); - Condition condition = FilterUtil.filterCondition(filter); - - assertTrue(condition.hasFilter()); - assertEquals(filter, condition.getFilter()); - } - - @Test - void testNestedCondition() { - String key = "nested"; - Filter filter = Filter.newBuilder().build(); - Condition condition = FilterUtil.nestedCondition(key, filter); - - assertTrue(condition.hasNested()); - assertEquals(key, condition.getNested().getKey()); - assertEquals(filter, condition.getNested().getFilter()); - } - - @Test - void testIsEmptyCondition() { - String key = "field"; - Condition condition = FilterUtil.isEmptyCondition(key); - - assertTrue(condition.hasIsEmpty()); - assertEquals(key, condition.getIsEmpty().getKey()); - } - - @Test - void testIsNullCondition() { - String key = "field"; - Condition condition = FilterUtil.isNullCondition(key); - - assertTrue(condition.hasIsNull()); - assertEquals(key, condition.getIsNull().getKey()); - } - - @Test - void testHasIdCondition() { - List pointIds = Arrays.asList(PointUtil.pointId(1), PointUtil.pointId(2)); - Condition condition = FilterUtil.hasIdCondition(pointIds); - - assertTrue(condition.hasHasId()); - assertEquals(pointIds, condition.getHasId().getHasIdList()); - } - - @Test - void testGeoPoint() { - double latitude = 10.0; - double longitude = 20.0; - GeoPoint geoPoint = FilterUtil.geoPoint(latitude, longitude); - - assertEquals(latitude, geoPoint.getLat()); - assertEquals(longitude, geoPoint.getLon()); - } - - @Test - void testMust() { - Condition condition1 = Condition.newBuilder().build(); - Condition condition2 = Condition.newBuilder().build(); - Filter filter = FilterUtil.must(condition1, condition2); - - assertEquals(Arrays.asList(condition1, condition2), filter.getMustList()); - } - - @Test - void testMustNot() { - Condition condition1 = Condition.newBuilder().build(); - Condition condition2 = Condition.newBuilder().build(); - Filter filter = FilterUtil.mustNot(condition1, condition2); - - assertEquals(Arrays.asList(condition1, condition2), filter.getMustNotList()); - } - - @Test - void testShould() { - Condition condition1 = Condition.newBuilder().build(); - Condition condition2 = Condition.newBuilder().build(); - Filter filter = FilterUtil.should(condition1, condition2); - - assertEquals(Arrays.asList(condition1, condition2), filter.getShouldList()); - } -} diff --git a/src/test/java/io/qdrant/client/utils/PayloadUtilTest.java b/src/test/java/io/qdrant/client/utils/PayloadUtilTest.java deleted file mode 100644 index 30353f6a..00000000 --- a/src/test/java/io/qdrant/client/utils/PayloadUtilTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package io.qdrant.client.utils; - -import static org.junit.jupiter.api.Assertions.*; - -import io.qdrant.client.grpc.JsonWithInt.ListValue; -import io.qdrant.client.grpc.JsonWithInt.NullValue; -import io.qdrant.client.grpc.JsonWithInt.Struct; -import io.qdrant.client.grpc.JsonWithInt.Value; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; - -class PayloadUtilTest { - - @Test - void testToPayloadStruct() { - // Test case 1: Empty input map - Map inputMap = new HashMap<>(); - Struct payloadStruct = PayloadUtil.toPayloadStruct(inputMap); - assertTrue(payloadStruct.getFieldsMap().isEmpty()); - - // Test case 2: Input map with different value types - inputMap.put("name", "Elon"); - inputMap.put("age", 52); - inputMap.put("isStudent", true); - payloadStruct = PayloadUtil.toPayloadStruct(inputMap); - assertEquals("Elon", payloadStruct.getFieldsMap().get("name").getStringValue()); - assertEquals(52, payloadStruct.getFieldsMap().get("age").getIntegerValue()); - assertEquals(true, payloadStruct.getFieldsMap().get("isStudent").getBoolValue()); - } - - @Test - void testToPayload() { - // Test case 1: Empty input map - Map inputMap = new HashMap<>(); - Map payload = PayloadUtil.toPayload(inputMap); - assertTrue(payload.isEmpty()); - - // Test case 2: Input map with different value types - inputMap.put("name", "Elon"); - inputMap.put("age", 52); - inputMap.put("isStudent", true); - payload = PayloadUtil.toPayload(inputMap); - assertEquals("Elon", payload.get("name").getStringValue()); - assertEquals(52, payload.get("age").getIntegerValue()); - assertEquals(true, payload.get("isStudent").getBoolValue()); - } - - @Test - void testStructtoMap() { - // Test case 1: Empty struct - Struct.Builder structBuilder = Struct.newBuilder(); - Struct struct = structBuilder.build(); - Map structMap = PayloadUtil.toMap(struct); - assertTrue(structMap.isEmpty()); - - // Test case 2: Struct with different value types - structBuilder.putFields("name", Value.newBuilder().setStringValue("Elon").build()); - structBuilder.putFields("age", Value.newBuilder().setIntegerValue(52).build()); - structBuilder.putFields("isStudent", Value.newBuilder().setBoolValue(true).build()); - struct = structBuilder.build(); - structMap = PayloadUtil.toMap(struct); - assertEquals("Elon", structMap.get("name")); - assertEquals(52, (int) structMap.get("age")); - assertEquals(true, structMap.get("isStudent")); - } - - @Test - void testtoMap() { - // Test case 1: Empty payload - Map payload = new HashMap<>(); - Map hashMap = PayloadUtil.toMap(payload); - assertTrue(hashMap.isEmpty()); - - // Test case 2: Payload with different value types - payload.put("name", Value.newBuilder().setStringValue("Elon").build()); - payload.put("age", Value.newBuilder().setIntegerValue(52).build()); - payload.put("isStudent", Value.newBuilder().setBoolValue(true).build()); - hashMap = PayloadUtil.toMap(payload); - assertEquals("Elon", hashMap.get("name")); - assertEquals(52, hashMap.get("age")); - assertEquals(true, hashMap.get("isStudent")); - } - - @Test - void testSetValue() { - // Test case 1: Set string value - Value.Builder valueBuilder = Value.newBuilder(); - PayloadUtil.setValue(valueBuilder, "Elon"); - assertEquals("Elon", valueBuilder.getStringValue()); - - // Test case 2: Set integer value - valueBuilder = Value.newBuilder(); - PayloadUtil.setValue(valueBuilder, 52); - assertEquals(52, valueBuilder.getIntegerValue()); - - // Test case 3: Set boolean value - valueBuilder = Value.newBuilder(); - PayloadUtil.setValue(valueBuilder, true); - assertEquals(true, valueBuilder.getBoolValue()); - } - - @Test - void testListToListValue() { - // Test case 1: Empty list - List list = new ArrayList<>(); - ListValue.Builder listValueBuilder = PayloadUtil.listToListValue(list); - assertTrue(listValueBuilder.getValuesList().isEmpty()); - - // Test case 2: List with different value types - list.add("Elon"); - list.add(52); - list.add(true); - listValueBuilder = PayloadUtil.listToListValue(list); - assertEquals("Elon", listValueBuilder.getValuesList().get(0).getStringValue()); - assertEquals(52, listValueBuilder.getValuesList().get(1).getIntegerValue()); - assertEquals(true, listValueBuilder.getValuesList().get(2).getBoolValue()); - } - - @Test - void testListValueToList() { - // Test case 1: Empty list value - ListValue.Builder listValueBuilder = ListValue.newBuilder(); - ListValue listValue = listValueBuilder.build(); - Object[] objectList = (Object[]) PayloadUtil.listValueToList(listValue); - assertTrue(objectList.length == 0); - - // Test case 2: List value with different value types - listValueBuilder.addValues(Value.newBuilder().setStringValue("Elon").build()); - listValueBuilder.addValues(Value.newBuilder().setIntegerValue(52).build()); - listValueBuilder.addValues(Value.newBuilder().setBoolValue(true).build()); - listValue = listValueBuilder.build(); - objectList = (Object[]) PayloadUtil.listValueToList(listValue); - assert (objectList instanceof Object[]); - - assertEquals("Elon", objectList[0]); - assertEquals(52, objectList[1]); - assertEquals(true, objectList[2]); - } - - @Test - void testValueToObject() { - // Test case 1: String value - Value value = Value.newBuilder().setStringValue("Elon").build(); - Object object = PayloadUtil.valueToObject(value); - assertEquals("Elon", object); - - // Test case 2: Integer value - value = Value.newBuilder().setIntegerValue(52).build(); - object = PayloadUtil.valueToObject(value); - assertEquals(52, object); - - // Test case 3: Boolean value - value = Value.newBuilder().setBoolValue(true).build(); - object = PayloadUtil.valueToObject(value); - assertEquals(true, object); - - // Test case 4: Null value - value = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); - object = PayloadUtil.valueToObject(value); - assertNull(object); - } -} diff --git a/src/test/java/io/qdrant/client/utils/PointUtilTest.java b/src/test/java/io/qdrant/client/utils/PointUtilTest.java deleted file mode 100644 index 727da2c9..00000000 --- a/src/test/java/io/qdrant/client/utils/PointUtilTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package io.qdrant.client.utils; - -import static org.junit.jupiter.api.Assertions.*; - -import io.qdrant.client.grpc.JsonWithInt.Value; -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.PointStruct; -import io.qdrant.client.grpc.Points.PointsIdsList; -import io.qdrant.client.grpc.Points.PointsSelector; -import io.qdrant.client.grpc.Points.ReadConsistency; -import io.qdrant.client.grpc.Points.ReadConsistencyType; -import io.qdrant.client.grpc.Points.Vector; -import io.qdrant.client.grpc.Points.WriteOrdering; -import io.qdrant.client.grpc.Points.WriteOrderingType; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; - -class PointUtilTest { - - @Test - void testCreatePointsSelectorWithLongIds() { - long[] pointIds = {1L, 2L, 3L}; - PointsSelector pointsSelector = PointUtil.createPointsSelector(pointIds); - - PointsIdsList expectedIdsList = - PointsIdsList.newBuilder() - .addAllIds( - Arrays.asList(PointUtil.pointId(1L), PointUtil.pointId(2L), PointUtil.pointId(3L))) - .build(); - - assertEquals(expectedIdsList, pointsSelector.getPoints()); - } - - @Test - void testCreatePointsSelectorWithStringIds() { - String[] pointIds = { - "123e4567-e89b-12d3-a456-426614174000", - "123e4567-e89b-12d3-a456-426614174001", - "123e4567-e89b-12d3-a456-426614174002" - }; - PointsSelector pointsSelector = PointUtil.createPointsSelector(pointIds); - - PointsIdsList expectedIdsList = - PointsIdsList.newBuilder() - .addAllIds( - Arrays.asList( - PointUtil.pointId("123e4567-e89b-12d3-a456-426614174000"), - PointUtil.pointId("123e4567-e89b-12d3-a456-426614174001"), - PointUtil.pointId("123e4567-e89b-12d3-a456-426614174002"))) - .build(); - - assertEquals(expectedIdsList, pointsSelector.getPoints()); - } - - @Test - void testCreatePointsSelectorWithIterable() { - List pointIds = - Arrays.asList(PointUtil.pointId(1L), PointUtil.pointId(2L), PointUtil.pointId(3L)); - PointsSelector pointsSelector = PointUtil.createPointsSelector(pointIds); - - PointsIdsList expectedIdsList = - PointsIdsList.newBuilder() - .addAllIds( - Arrays.asList(PointUtil.pointId(1L), PointUtil.pointId(2L), PointUtil.pointId(3L))) - .build(); - - assertEquals(expectedIdsList, pointsSelector.getPoints()); - } - - @Test - void testPointsSelector() { - Filter filter = Filter.newBuilder().build(); - PointsSelector pointsSelector = PointUtil.pointsSelector(filter); - - assertEquals(filter, pointsSelector.getFilter()); - } - - @Test - void testPointIdWithLong() { - long num = 42L; - PointId pointId = PointUtil.pointId(num); - - assertEquals(num, pointId.getNum()); - } - - @Test - void testPointIdWithString() { - String uuid = "123e4567-e89b-12d3-a456-426614174000"; - PointId pointId = PointUtil.pointId(uuid); - - assertEquals(uuid, pointId.getUuid()); - } - - @Test - void testPointIdWithUUID() { - UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); - PointId pointId = PointUtil.pointId(uuid); - - assertEquals(uuid.toString(), pointId.getUuid()); - } - - @Test - void testPointWithUUID() { - UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); - Vector vector = Vector.newBuilder().build(); - Map payload = Collections.emptyMap(); - PointStruct pointStruct = PointUtil.point(uuid, vector, payload); - - assertEquals(uuid.toString(), pointStruct.getId().getUuid()); - assertEquals(vector, pointStruct.getVectors().getVector()); - assertEquals(payload, pointStruct.getPayloadMap()); - } - - @Test - void testPointWithLongId() { - long id = 42L; - Vector vector = Vector.newBuilder().build(); - Map payload = Collections.emptyMap(); - PointStruct pointStruct = PointUtil.point(id, vector, payload); - - assertEquals(id, pointStruct.getId().getNum()); - assertEquals(vector, pointStruct.getVectors().getVector()); - assertEquals(payload, pointStruct.getPayloadMap()); - } - - @Test - void testPointWithPointId() { - PointId id = PointUtil.pointId(42L); - Vector vector = Vector.newBuilder().build(); - Map payload = Collections.emptyMap(); - PointStruct pointStruct = PointUtil.point(id, vector, payload); - - assertEquals(id, pointStruct.getId()); - assertEquals(vector, pointStruct.getVectors().getVector()); - assertEquals(payload, pointStruct.getPayloadMap()); - } - - @Test - void testNamedPointWithLongId() { - Long id = 42L; - String vectorName = "vector"; - float[] vectorData = {1.0f, 2.0f, 3.0f}; - Map payload = Collections.emptyMap(); - PointStruct pointStruct = PointUtil.namedPoint(id, vectorName, vectorData, payload); - - assertEquals(PointUtil.pointId(id), pointStruct.getId()); - assertEquals( - VectorUtil.namedVector(vectorName, vectorData), pointStruct.getVectors().getVectors()); - assertEquals(payload, pointStruct.getPayloadMap()); - } - - @Test - void testNamedPointWithPointId() { - PointId id = PointUtil.pointId(42L); - String vectorName = "vector"; - float[] vectorData = {1.0f, 2.0f, 3.0f}; - Map payload = Collections.emptyMap(); - PointStruct pointStruct = PointUtil.namedPoint(id, vectorName, vectorData, payload); - - assertEquals(id, pointStruct.getId()); - assertEquals( - VectorUtil.namedVector(vectorName, vectorData), pointStruct.getVectors().getVectors()); - assertEquals(payload, pointStruct.getPayloadMap()); - } - - @Test - void testOrdering() { - WriteOrderingType orderingType = WriteOrderingType.Medium; - WriteOrdering ordering = PointUtil.ordering(orderingType); - - assertEquals(orderingType, ordering.getType()); - } - - @Test - void testConsistency() { - ReadConsistencyType consistencyType = ReadConsistencyType.Quorum; - ReadConsistency consistency = PointUtil.consistency(consistencyType); - - assertEquals(consistencyType, consistency.getType()); - } -} diff --git a/src/test/java/io/qdrant/client/utils/SelectorUtilTest.java b/src/test/java/io/qdrant/client/utils/SelectorUtilTest.java deleted file mode 100644 index 0735867d..00000000 --- a/src/test/java/io/qdrant/client/utils/SelectorUtilTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.qdrant.client.utils; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.PointId; -import io.qdrant.client.grpc.Points.PointsSelector; -import io.qdrant.client.grpc.Points.WithPayloadSelector; -import io.qdrant.client.grpc.Points.WithVectorsSelector; -import java.util.Arrays; -import java.util.List; -import org.junit.jupiter.api.Test; - -class SelectorUtilTest { - - @Test - void testWithPayload() { - WithPayloadSelector selector = SelectorUtil.withPayload(); - assertTrue(selector.getEnable()); - } - - @Test - void testWithVectors() { - WithVectorsSelector selector = SelectorUtil.withVectors(); - assertTrue(selector.getEnable()); - } - - @Test - void testWithPayloadWithFields() { - String[] fields = {"field1", "field2"}; - WithPayloadSelector selector = SelectorUtil.withPayload(fields); - List expectedFields = Arrays.asList(fields); - assertEquals(expectedFields, selector.getInclude().getFieldsList()); - } - - @Test - void testWithVectorsWithNames() { - String[] vectors = {"vector1", "vector2"}; - WithVectorsSelector selector = SelectorUtil.withVectors(vectors); - List expectedVectors = Arrays.asList(vectors); - assertEquals(expectedVectors, selector.getInclude().getNamesList()); - } - - @Test - void testIdsSelectorWithList() { - List ids = Arrays.asList(PointUtil.pointId(1), PointUtil.pointId(2)); - PointsSelector selector = SelectorUtil.idsSelector(ids); - assertEquals(ids, selector.getPoints().getIdsList()); - } - - @Test - void testIdsSelectorWithArray() { - PointId[] ids = {PointUtil.pointId(1), PointUtil.pointId(2)}; - PointsSelector selector = SelectorUtil.idsSelector(ids); - List expectedIds = Arrays.asList(ids); - assertEquals(expectedIds, selector.getPoints().getIdsList()); - } - - @Test - void testFilterSelector() { - Filter filter = Filter.newBuilder().build(); - PointsSelector selector = SelectorUtil.filterSelector(filter); - assertEquals(filter, selector.getFilter()); - } -} diff --git a/src/test/java/io/qdrant/client/utils/VectorUtilTest.java b/src/test/java/io/qdrant/client/utils/VectorUtilTest.java deleted file mode 100644 index b7dd2749..00000000 --- a/src/test/java/io/qdrant/client/utils/VectorUtilTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package io.qdrant.client.utils; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import io.qdrant.client.grpc.Points.NamedVectors; -import io.qdrant.client.grpc.Points.PointVectors; -import io.qdrant.client.grpc.Points.Vector; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; - -class VectorUtilTest { - - @Test - void testVectorFromList() { - List vectorData = Arrays.asList(1.0f, 2.0f, 3.0f); - Vector vector = VectorUtil.toVector(vectorData); - - assertEquals(vectorData, vector.getDataList()); - } - - @Test - void testVectorFromArray() { - float[] vectorData = {1.0f, 2.0f, 3.0f}; - Vector vector = VectorUtil.toVector(vectorData); - - assertEquals(Arrays.asList(1.0f, 2.0f, 3.0f), vector.getDataList()); - } - - @Test - void testNamedVectorFromList() { - String name = "vector1"; - List vectorData = Arrays.asList(1.0f, 2.0f, 3.0f); - NamedVectors namedVector = VectorUtil.namedVector(name, vectorData); - - assertTrue(namedVector.getVectorsMap().containsKey(name)); - assertEquals(vectorData, namedVector.getVectorsMap().get(name).getDataList()); - } - - @Test - void testNamedVectorFromArray() { - String name = "vector1"; - float[] vectorData = {1.0f, 2.0f, 3.0f}; - NamedVectors namedVector = VectorUtil.namedVector(name, vectorData); - - assertTrue(namedVector.getVectorsMap().containsKey(name)); - assertEquals( - Arrays.asList(1.0f, 2.0f, 3.0f), namedVector.getVectorsMap().get(name).getDataList()); - } - - @Test - void testNamedVectorsFromMap() { - String name1 = "vector1"; - String name2 = "vector2"; - Map vectorsMap = new HashMap<>(); - vectorsMap.put(name1, VectorUtil.toVector(1.0f, 2.0f, 3.0f)); - vectorsMap.put(name2, VectorUtil.toVector(4.0f, 5.0f, 6.0f)); - NamedVectors namedVectors = VectorUtil.namedVectors(vectorsMap); - - assertEquals(vectorsMap, namedVectors.getVectorsMap()); - } - - @Test - void testPointVectors() { - String id = "123e4567-e89b-12d3-a456-426614174000"; - String name = "vector1"; - float[] vectorData = {1.0f, 2.0f, 3.0f}; - PointVectors pointVectors = VectorUtil.pointVectors(id, name, vectorData); - - assertEquals(PointUtil.pointId(id), pointVectors.getId()); - assertTrue(pointVectors.getVectors().getVectors().getVectorsMap().containsKey(name)); - assertEquals( - Arrays.asList(1.0f, 2.0f, 3.0f), - pointVectors.getVectors().getVectors().getVectorsMap().get(name).getDataList()); - } -} diff --git a/tools/mvn_test.sh b/tools/mvn_test.sh deleted file mode 100644 index 5548a21b..00000000 --- a/tools/mvn_test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -set -ex - -function stop_docker() -{ - echo "Stopping qdrant_test" - docker stop qdrant_test -} - -# Ensure current path is project root -cd "$(dirname "$0")/../" - -QDRANT_VERSION='v1.6.1' - -QDRANT_HOST='localhost:6333' - -docker run -d --rm \ - -p 6333:6333 \ - -p 6334:6334 \ - --name qdrant_test qdrant/qdrant:${QDRANT_VERSION} - -trap stop_docker SIGINT -trap stop_docker ERR - -until curl --output /dev/null --silent --get --fail http://$QDRANT_HOST/collections; do - printf 'Waiting for the Qdrant server to start...' - sleep 5 -done - -mvn test - -stop_docker \ No newline at end of file From 0f6b68bf2d7359f55517e982ae745f982fb20827 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Tue, 12 Dec 2023 22:10:38 +1000 Subject: [PATCH 2/2] Update README --- README.md | 192 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 106 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 12b4950c..2c8757c5 100644 --- a/README.md +++ b/README.md @@ -31,133 +31,153 @@ Java client library with handy utility methods and overloads for interfacing wit To install the library, add the following lines to your build config file. #### Maven + ```xml io.qdrant client - 1.0 + 1.7-SNAPSHOT ``` #### Scala SBT + ```sbt -libraryDependencies += "io.qdrant" % "client" % "1.0" +libraryDependencies += "io.qdrant" % "client" % "1.7-SNAPSHOT" ``` #### Gradle + ```gradle -implementation 'io.qdrant:client:1.0' +implementation 'io.qdrant:client:1.7-SNAPSHOT' ``` ## ๐Ÿ“– Documentation + - [`QdrantClient` Reference](https://qdrant.github.io/java-client/io/qdrant/client/QdrantClient.html#constructor-detail) -- [Utility Methods Reference](https://qdrant.github.io/java-client/io/qdrant/client/utils/package-summary.html) -## ๐Ÿ”Œ Connecting to Qdrant +## ๐Ÿ”Œ Getting started -> [!NOTE] -> The library uses Qdrant's GRPC interface. The default port being `6334`. -> -> Uses `TLS` if the URL protocol is `https`, plaintext otherwise. +### Creating a client -#### Connecting to a local Qdrant instance -```java -import io.qdrant.client.QdrantClient; +A client can be instantiated with -QdrantClient client = new QdrantClient("http://localhost:6334"); +```java +QdrantClient client = + new QdrantClient(QdrantGrpcClient.newBuilder("localhost").build()); ``` +which creates a client that will connect to Qdrant on https://localhost:6334. -#### Connecting to Qdrant cloud -```java -import io.qdrant.client.QdrantClient; +Internally, the high level client uses a low level gRPC client to interact with +Qdrant. Additional constructor overloads provide more control over how the gRPC +client is configured. The following example configures a client to use TLS, +validating the certificate using the root CA to verify the server's identity +instead of the system's default, and also configures API key authentication: -QdrantClient client = new QdrantClient("https://xyz-eg.eu-central.aws.cloud.qdrant.io:6334", ""); +```java +ManagedChannel channel = Grpc.newChannelBuilder( + "localhost:6334", + TlsChannelCredentials.newBuilder() + .trustManager(new File("ssl/ca.crt")) + .build()) +.build(); + +QdrantClient client = new QdrantClient( + QdrantGrpcClient.newBuilder(channel) + .withApiKey("") + .build()); ``` -## ๐Ÿงช Example Usage -
-Click to expand example - +The client implements [`AutoCloseable`](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html), +though a client will typically be created once and used for the lifetime of the +application. When a client is constructed by passing a `ManagedChannel`, the +client does not shut down the channel on close by default. The client can be +configured to shut down the channel on close with -#### You can connect to Qdrant by instantiating a [QdrantClient](https://qdrant.github.io/java-client/io/qdrant/client/QdrantClient.html) instance. ```java -import io.qdrant.client.QdrantClient; +ManagedChannel channel = Grpc.newChannelBuilder( + "localhost:6334", + TlsChannelCredentials.create()) +.build(); + +QdrantClient client = new QdrantClient( + QdrantGrpcClient.newBuilder(channel, true) + .withApiKey("") + .build()); +``` -QdrantClient client = new QdrantClient("http://localhost:6334"); +All client methods return `ListenableFuture`. -System.out.println(client.listCollections()); -``` -*Output*: -``` -collections { -name: "Documents" -} -collections { -name: "some_collection" -} -time: 7.04541E-4 -``` +### Working with collections -#### We can now perform operations on the DB. Like creating a collection, adding a point. -The library offers handy utility methods for constructing GRPC structures. +Once a client has been created, create a new collection ```java -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.qdrant.client.utils.*; +client.createCollectionAsync("my_collection", + VectorParams.newBuilder() + .setDistance(Distance.Cosine) + .setSize(4) + .build()) + .get(); +``` -String collectionName = "Documents"; +Insert vectors into a collection -client.recreateCollection(collectionName, 6, Distance.Cosine); +```java +// import static convenience methods +import static io.qdrant.client.PointIdFactory.id; +import static io.qdrant.client.ValueFactory.value; +import static io.qdrant.client.VectorsFactory.vector; + +Random random = new Random(); +List points = IntStream.range(1, 101) + .mapToObj(i -> PointStruct.newBuilder() + .setId(id(i)) + .setVectors(vector(IntStream.range(1, 101) + .mapToObj(v -> random.nextFloat()) + .collect(Collectors.toList()))) + .putAllPayload(ImmutableMap.of( + "color", value("red"), + "rand_number", value(i % 10)) + ) + .build() + ) + .collect(Collectors.toList()); + +UpdateResult updateResult = client.upsertAsync("my_collection", points).get(); +``` -Map map = new HashMap<>(); -map.put("name", "John Doe"); -map.put("age", 42); -map.put("married", true); +Search for similar vectors -PointStruct point = - PointUtil.point( - 0, - VectorUtil.toVector(0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f), - PayloadUtil.toPayload(map)); -List points = Arrays.asList(point); -client.upsertPoints(collectionName, points, null); +```java +List queryVector = IntStream.range(1, 101) + .mapToObj(v -> random.nextFloat()) + .collect(Collectors.toList()); + +List points = client.searchAsync(SearchPoints.newBuilder() + .setCollectionName("my_collection") + .addAllVector(queryVector) + .setLimit(5) + .build() +).get(); ``` -#### Performing a search on the vectors with filtering +Search for similar vectors with filtering condition + ```java -import io.qdrant.client.grpc.Points.Filter; -import io.qdrant.client.grpc.Points.SearchPoints; -import io.qdrant.client.grpc.Points.SearchResponse; - -import io.qdrant.client.utils.*; - -Filter filter = FilterUtil.must(FilterUtil.fieldCondition("age", FilterUtil.match(42))); - -SearchPoints request = SearchPoints.newBuilder() - .setCollectionName(collectionName) - .addAllVector(Arrays.asList(0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f)) - .setFilter(filter) - .setWithPayload(SelectorUtil.withPayload()) - .setLimit(10) - .build(); -SearchResponse result = client.searchPoints(request); - -ScoredPoint result = results.getResult(0); - -System.out.println("Similarity: " + result.getScore()); -System.out.println("Payload: " + PayloadUtil.toMap(result.getPayload())); -``` -*Output*: +// import static convenience methods +import static io.qdrant.client.ConditionFactory.range; + +List points = client.searchAsync(SearchPoints.newBuilder() + .setCollectionName("my_collection") + .addAllVector(queryVector) + .setFilter(Filter.newBuilder() + .addMust(range("rand_number", Range.newBuilder().setGte(3).build())) + .build()) + .setLimit(5) + .build() +).get(); ``` -Similarity: 0.9999999 -Payload: {name=John Doe, married=true, age=42} -``` - -
## โš–๏ธ LICENSE