GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - qdrant/java-client: Official Java client for Qdrant

BranchesTags
Open more actions menu

Latest commit

 

History

139 Commits
139 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.idea
.idea
 
 
buildSrc
buildSrc
 
 
example
example
 
 
gradle/wrapper
gradle/wrapper
 
 
resources
resources
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Qdrant   Java

Java library for the Qdrant vector search engine.

Javadoc Tests Apache 2.0 License Discord Roadmap 2024

Qdrant Java Client

Java client library with handy utility methods and overloads for interfacing with Qdrant.

📥 Installation

Important

Requires Java 8 or above.

To install the library, add the following lines to your build config file.

Maven

<dependency>
  <groupId>io.qdrant</groupId>
  <artifactId>client</artifactId>
  <version>1.20.0</version>
</dependency>

SBT

libraryDependencies += "io.qdrant" % "client" % "1.20.0"

Gradle

implementation 'io.qdrant:client:1.20.0'

Note

Please make sure to include all necessary dependencies listed here in your project.

📖 Documentation

  • Usage examples are available throughout the Qdrant documentation and API Reference.
  • JavaDoc Reference

🔌 Getting started

Creating a client

A client can be instantiated with

QdrantClient client = 
  new QdrantClient(QdrantGrpcClient.newBuilder("localhost").build());

which creates a client that will connect to Qdrant on https://localhost:6334.

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:

ManagedChannel channel = Grpc.newChannelBuilder(
  "localhost:6334",
  TlsChannelCredentials.newBuilder()
    .trustManager(new File("ssl/ca.crt"))
    .build())
.build();

QdrantClient client = new QdrantClient(
  QdrantGrpcClient.newBuilder(channel)
    .withApiKey("<apikey>")
    .build());

The client implements AutoCloseable, 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 closing with

ManagedChannel channel = Grpc.newChannelBuilder(
  "localhost:6334", 
  TlsChannelCredentials.create())
.build();

QdrantClient client = new QdrantClient(
  QdrantGrpcClient.newBuilder(channel, true)
    .withApiKey("<apikey>")
    .build());

All client methods return ListenableFuture<T>.

Working with collections

Once a client has been created, create a new collection

client.createCollectionAsync("{collection_name}",
  VectorParams.newBuilder()
    .setDistance(Distance.Cosine)
    .setSize(4)
    .build())
  .get();

Insert vectors into a collection

// import static convenience methods
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;

List<PointStruct> points =
    List.of(
        PointStruct.newBuilder()
            .setId(id(1))
            .setVectors(vectors(0.32f, 0.52f, 0.21f, 0.52f))
            .putAllPayload(
                Map.of(
                    "color", value("red"),
                    "rand_number", value(32)))
            .build(),
        PointStruct.newBuilder()
            .setId(id(2))
            .setVectors(vectors(0.42f, 0.52f, 0.67f, 0.632f))
            .putAllPayload(
                Map.of(
                    "color", value("black"),
                    "rand_number", value(53),
                    "extra_field", value(true)))
            .build());

UpdateResult updateResult = client.upsertAsync("{collection_name}", points).get();

Search for similar vectors

List<ScoredPoint> points =
    client
        .searchAsync(
            SearchPoints.newBuilder()
                .setCollectionName("{collection_name}")
                .addAllVector(List.of(0.6235f, 0.123f, 0.532f, 0.123f))
                .setLimit(5)
                .build())
        .get();

Search for similar vectors with filtering condition

// import static convenience methods
import static io.qdrant.client.ConditionFactory.range;

List<ScoredPoint> points = client.searchAsync(SearchPoints.newBuilder()
  .setCollectionName("{collection_name}")
  .addAllVector(List.of(0.6235f, 0.123f, 0.532f, 0.123f))
  .setFilter(Filter.newBuilder()
    .addMust(range("rand_number", Range.newBuilder().setGte(3).build()))
    .build())
  .setLimit(5)
  .build()
).get();

⚖️ LICENSE

Apache 2.0

About

Official Java client for Qdrant

qdrant.github.io/java-client

Topics

grpc-clientqdrant-clientvector-databasevector-searchvector-search-engine

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity
Custom properties

Stars

100 stars

Watchers

5 watching

Forks

19 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.