Qdrant improvements
- Update docs - Allow colleciton auto-creation if missing - Add cloud IT : QdrantVectorStoreCloudAutoConfigurationIT - Add auto-configuration properties tests: PgVectorStorePropertiesTests
This commit is contained in:
@@ -1 +1,22 @@
|
||||
Qdrant Vector Store
|
||||
# Qdrant Vector Store
|
||||
|
||||
[Reference Documentation](https://docs.spring.io/spring-ai/reference/0.8-SNAPSHOT/api/vectordbs/qdrant.html#qdrant-vectorstore-properties)
|
||||
|
||||
## Run locally
|
||||
|
||||
### Accessing the Web UI
|
||||
|
||||
First, run the Docker container:
|
||||
|
||||
```
|
||||
docker run -p 6333:6333 -p 6334:6334 \
|
||||
-v $(pwd)/qdrant_storage:/qdrant/storage:z \
|
||||
qdrant/qdrant
|
||||
```
|
||||
|
||||
The GUI is available at http://localhost:6333/dashboard
|
||||
|
||||
## Qdrant references
|
||||
|
||||
- https://qdrant.tech/documentation/interfaces/
|
||||
- https://github.com/qdrant/java-client
|
||||
|
||||
@@ -30,10 +30,13 @@ import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.embedding.EmbeddingClient;
|
||||
import org.springframework.ai.vectorstore.SearchRequest;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
import io.qdrant.client.grpc.JsonWithInt.Value;
|
||||
import io.qdrant.client.grpc.Points.Filter;
|
||||
import io.qdrant.client.grpc.Points.PointId;
|
||||
@@ -47,9 +50,10 @@ import io.qdrant.client.grpc.Points.UpdateStatus;
|
||||
* and similarity searching of documents in a Qdrant collection.
|
||||
*
|
||||
* @author Anush Shetty
|
||||
* @author Christian Tzolov
|
||||
* @since 0.8.1
|
||||
*/
|
||||
public class QdrantVectorStore implements VectorStore {
|
||||
public class QdrantVectorStore implements VectorStore, InitializingBean {
|
||||
|
||||
private static final String CONTENT_FIELD_NAME = "doc_content";
|
||||
|
||||
@@ -326,4 +330,25 @@ public class QdrantVectorStore implements VectorStore {
|
||||
return doubleList.stream().map(d -> d.floatValue()).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// Create the collection if it does not exist.
|
||||
if (!isCollectionExists()) {
|
||||
var vectorParams = VectorParams.newBuilder()
|
||||
.setDistance(Distance.Cosine)
|
||||
.setSize(this.embeddingClient.dimensions())
|
||||
.build();
|
||||
this.qdrantClient.createCollectionAsync(this.collectionName, vectorParams).get();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCollectionExists() {
|
||||
try {
|
||||
return this.qdrantClient.listCollectionsAsync().get().stream().anyMatch(c -> c.equals(this.collectionName));
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user