Skip to content

Commit

Permalink
Feat Version 1.1.0 (#5)
Browse files Browse the repository at this point in the history
* fix indexCreate add indexDelete

* fix plural

* fix plural

* feat: add vectors delete

* feat: update vectors

* Update README.md
  • Loading branch information
henomis authored Nov 25, 2023
1 parent 5d0f4b1 commit b4d395a
Show file tree
Hide file tree
Showing 26 changed files with 487 additions and 113 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Unofficial Qdrant Go SDK

# Unofficial Go client for Qdrant vector search engine

[![GoDoc](https://godoc.org/github.com/henomis/qdrant-go?status.svg)](https://godoc.org/github.com/henomis/qdrant-go) [![Go Report Card](https://goreportcard.com/badge/github.com/henomis/qdrant-go)](https://goreportcard.com/report/github.com/henomis/qdrant-go) [![GitHub release](https://img.shields.io/github/release/henomis/qdrant-go.svg)](https://github.com/henomis/qdrant-go/releases)

Expand All @@ -12,14 +11,15 @@ This is [Qdrant](https://qdrant.tech/)'s **unofficial** Go client, designed to e
## API support

### collections

- ✅ list
- ✅ create
- ✅ collect info
- ✅ update
- ✅ delete
- ❌ update aliases
- ✅ create index
- delete index
- delete index
- ❌ cluster info
- ❌ update cluster setup
- ❌ list aliases
Expand All @@ -29,14 +29,14 @@ This is [Qdrant](https://qdrant.tech/)'s **unofficial** Go client, designed to e
- ❌ delete snapshot
- ❌ download snapshot

### points

### points
- ✅ get point
- ✅ get points
- ✅ upsert points
- ✅ delete points
- update vectors
- delete vectors
- update vectors
- delete vectors
- ❌ set payload
- ❌ overwrite payload
- ❌ delete payload
Expand All @@ -51,13 +51,15 @@ This is [Qdrant](https://qdrant.tech/)'s **unofficial** Go client, designed to e
- ❌ count points

### cluster

- ❌ cluster status info
- ❌ tries to recover current peer Raft state
- ❌ remove peer
- ❌ collection cluster info
- ❌ update collection cluster setup

### snapshots

- ❌ recover from uploaded snapshot
- ❌ recover from snapshot
- ❌ list collection snapshots
Expand All @@ -70,29 +72,32 @@ This is [Qdrant](https://qdrant.tech/)'s **unofficial** Go client, designed to e
- ❌ download storage snapshot

### service

- ❌ collect telemetry data
- ❌ collect Prometheus metrics data
- ❌ set lock options
- ❌ get lock options


## Getting started

### Installation

You can load qdrant-go into your project by using:

```
go get github.com/henomis/qdrant-go
```

### Run Qdrant

You can run Qdrant using Docker:

```shell
docker run -p 6333:6333 --name qdrant --rm -v $(pwd)/config.yaml:/qdrant/config/production.yaml qdrant/qdrant
```

config.yaml file:

```yaml
service:
api_key: secret-api-key
Expand All @@ -104,7 +109,6 @@ Please refer to the [official documentation](https://qdrant.tech/) for more info
The only thing you need to start using Qdrant's APIs is the API key. Copy and paste it in the corresponding place in the code, select the API and the parameters you want to use, and that's it.
### Usage
Please refer to the [examples folder](examples/cmd/) to see how to use the SDK.
Expand Down Expand Up @@ -152,4 +156,4 @@ func main() {

## Who uses qdrant-go?

* [LinGoose](https://github.com/henomis/lingoose) Go framework for building awesome LLM apps
- [LinGoose](https://github.com/henomis/lingoose) Go framework for building awesome LLM apps
34 changes: 34 additions & 0 deletions examples/cmd/index/create/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"context"
"fmt"

qdrantgo "github.com/henomis/qdrant-go"
"github.com/henomis/qdrant-go/request"
"github.com/henomis/qdrant-go/response"
)

func main() {

client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.IndexCreate{}
err := client.IndexCreate(
context.Background(),
&request.IndexCreate{
CollectionName: "test",
Wait: &wait,
FieldName: "test_field",
FieldSchema: "keyword",
},
resp,
)
if err != nil {
panic(err)
}

fmt.Printf("resp: %#v\n", resp)

}
33 changes: 33 additions & 0 deletions examples/cmd/index/delete/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"context"
"fmt"

qdrantgo "github.com/henomis/qdrant-go"
"github.com/henomis/qdrant-go/request"
"github.com/henomis/qdrant-go/response"
)

func main() {

client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.IndexDelete{}
err := client.IndexDelete(
context.Background(),
&request.IndexDelete{
CollectionName: "test",
Wait: &wait,
FieldName: "test_field",
},
resp,
)
if err != nil {
panic(err)
}

fmt.Printf("resp: %#v\n", resp)

}
6 changes: 3 additions & 3 deletions examples/cmd/point/delete/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func main() {
client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.PointDelete{}
err := client.PointDelete(
resp := &response.PointsDelete{}
err := client.PointsDelete(
context.Background(),
&request.PointDelete{
&request.PointsDelete{
CollectionName: "test",
Wait: &wait,
Filter: request.Filter{
Expand Down
6 changes: 3 additions & 3 deletions examples/cmd/point/search/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func main() {
client := qdrantgo.New("http://localhost:6333", "")

withPayload := true
resp := &response.PointSearch{}
err := client.PointSearch(
resp := &response.PointsSearch{}
err := client.PointsSearch(
context.Background(),
&request.PointSearch{
&request.PointsSearch{
CollectionName: "test",
Vector: []float64{1.1, 2.2, 3.3, 4.4},
Limit: 10,
Expand Down
6 changes: 3 additions & 3 deletions examples/cmd/point/upsert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func main() {
client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.PointUpsert{}
err := client.PointUpsert(
resp := &response.PointsUpsert{}
err := client.PointsUpsert(
context.Background(),
&request.PointUpsert{
&request.PointsUpsert{
CollectionName: "test",
Wait: &wait,
Points: []request.Point{
Expand Down
33 changes: 33 additions & 0 deletions examples/cmd/vector/delete/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"context"
"fmt"

qdrantgo "github.com/henomis/qdrant-go"
"github.com/henomis/qdrant-go/request"
"github.com/henomis/qdrant-go/response"
)

func main() {

client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.VectorsDelete{}
err := client.VectorsDelete(
context.Background(),
&request.VectorsDelete{
CollectionName: "test",
Wait: &wait,
Vector: []string{"vec1"},
},
resp,
)
if err != nil {
panic(err)
}

fmt.Printf("resp: %#v\n", resp)

}
38 changes: 38 additions & 0 deletions examples/cmd/vector/update/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"context"
"fmt"

qdrantgo "github.com/henomis/qdrant-go"
"github.com/henomis/qdrant-go/request"
"github.com/henomis/qdrant-go/response"
)

func main() {

client := qdrantgo.New("http://localhost:6333", "")

wait := true
resp := &response.VectorsUpdate{}
err := client.VectorsUpdate(
context.Background(),
&request.VectorsUpdate{
CollectionName: "test",
Wait: &wait,
Points: []request.PointVectors{
{
ID: "45b07125-f592-414f-a9d0-160c8ecc283a",
Vector: []float64{5, 6, 7, 8},
},
},
},
resp,
)
if err != nil {
panic(err)
}

fmt.Printf("resp: %#v\n", resp)

}
42 changes: 33 additions & 9 deletions qdrantgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,34 @@ func (c *Client) IndexCreate(
return c.restClient.Put(ctx, req, res)
}

func (c *Client) PointUpsert(
func (c *Client) IndexDelete(
ctx context.Context,
req *request.PointUpsert,
res *response.PointUpsert,
req *request.IndexDelete,
res *response.IndexDelete,
) error {
return c.restClient.Delete(ctx, req, res)
}

func (c *Client) PointsUpsert(
ctx context.Context,
req *request.PointsUpsert,
res *response.PointsUpsert,
) error {
return c.restClient.Put(ctx, req, res)
}

func (c *Client) PointSearch(
func (c *Client) PointsSearch(
ctx context.Context,
req *request.PointSearch,
res *response.PointSearch,
req *request.PointsSearch,
res *response.PointsSearch,
) error {
return c.restClient.Post(ctx, req, res)
}

func (c *Client) PointDelete(
func (c *Client) PointsDelete(
ctx context.Context,
req *request.PointDelete,
res *response.PointDelete,
req *request.PointsDelete,
res *response.PointsDelete,
) error {
return c.restClient.Post(ctx, req, res)
}
Expand All @@ -120,3 +128,19 @@ func (c *Client) PointsGet(
) error {
return c.restClient.Post(ctx, req, res)
}

func (c *Client) VectorsUpdate(
ctx context.Context,
req *request.VectorsUpdate,
res *response.VectorsUpdate,
) error {
return c.restClient.Put(ctx, req, res)
}

func (c *Client) VectorsDelete(
ctx context.Context,
req *request.VectorsDelete,
res *response.VectorsDelete,
) error {
return c.restClient.Post(ctx, req, res)
}
2 changes: 1 addition & 1 deletion request/collectionDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type CollectionDelete struct {
}

func (c *CollectionDelete) Path() (string, error) {
var urlValues restclientgo.URLValues
var urlValues = restclientgo.URLValues{}
urlValues.AddInt("timeout", c.Timeout)

parameters := ""
Expand Down
6 changes: 3 additions & 3 deletions request/indexCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ type IndexCreate struct {
}

func (c *IndexCreate) Path() (string, error) {
var urlValues restclientgo.URLValues
urlValues.AddBool("timeout", c.Wait)
var urlValues = restclientgo.URLValues{}
urlValues.AddBool("wait", c.Wait)
urlValues.Add("ordering", (*string)(c.Ordering))

parameters := ""
if len(urlValues) > 0 {
parameters = "?" + urlValues.Encode()
}

return fmt.Sprintf("/collections/%s%s", c.CollectionName, parameters), nil
return fmt.Sprintf("/collections/%s/index%s", c.CollectionName, parameters), nil
}

func (c *IndexCreate) Encode() (io.Reader, error) {
Expand Down
Loading

0 comments on commit b4d395a

Please sign in to comment.