Skip to content

Commit

Permalink
📝 update document
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi committed Mar 2, 2021
1 parent db5f328 commit 1a89537
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
66 changes: 63 additions & 3 deletions docs/tutorial/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ This chapter shows how to perform a search action in Vald with fashion-mnist dat

```go
for i := range ids [:insertCount] {
if i%10 == 0 {
glg.Infof("Inserted %d", i)
}
_, err := client.Insert(ctx, &payload.Insert_Request{
Vector: &payload.Object_Vector{
Id: ids[i],
Expand All @@ -313,6 +310,9 @@ This chapter shows how to perform a search action in Vald with fashion-mnist dat
if err != nil {
glg.Fatal(err)
}
if i%10 == 0 {
glg.Infof("Inserted %d", i)
}
}
```

Expand Down Expand Up @@ -359,6 +359,29 @@ This chapter shows how to perform a search action in Vald with fashion-mnist dat

</details>

1. Remove

- Remove indexed 400 training datasets from the Vald agent.
<details><summary>example code</summary><br>

```go
for i := range ids [:insertCount] {
_, err := client.Remove(ctx, &payload.Remove_Request{
Id: &payload.Object_ID{
Id: ids[i],
},
})
if err != nil {
glg.Fatal(err)
}
if i%10 == 0 {
glg.Infof("Removed %d", i)
}
}
```

</details>

```bash
# run example
go run main.go
Expand Down Expand Up @@ -634,6 +657,43 @@ This chapter uses [NGT](https://github.com/yahoojapan/ngt) as Vald Agent to perf

</details>

1. Remove

- Remove indexed 400 training datasets from the Vald agent.
<details><summary>example code</summary><br>

```go
for i := range ids [:insertCount] {
_, err := client.Remove(ctx, &payload.Remove_Request{
Id: &payload.Object_ID{
Id: ids[i],
},
})
if err != nil {
glg.Fatal(err)
}
if i%10 == 0 {
glg.Infof("Removed %d", i)
}
}
```

</details>


- Remove manually instead of waiting for auto indexing.
If you run below code, the indexes will be removed from the Vald Agent and the Backup file.
<detail><summary>example code</summary><br>

```go
_, err = client.SaveIndex(ctx, &payload.Empty{})
if err != nil {
glg.Fatal(err)
}
```

</detail>

```bash
# run example
go run main.go
Expand Down
12 changes: 6 additions & 6 deletions example/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ func main() {
glg.Infof("Start Inserting %d training vector to Vald", insertCount)
// Insert 400 example vectors into Vald cluster
for i := range ids[:insertCount] {
if i%10 == 0 {
glg.Infof("Inserted: %d", i+10)
}
// Calls `Insert` function of Vald client.
// Sends set of vector and id to server via gRPC.
_, err := client.Insert(ctx, &payload.Insert_Request{
Expand All @@ -94,6 +91,9 @@ func main() {
if err != nil {
glg.Fatal(err)
}
if i%10 == 0 {
glg.Infof("Inserted: %d", i+10)
}
}
glg.Info("Finish Inserting dataset. \n\n")

Expand Down Expand Up @@ -132,9 +132,6 @@ func main() {
glg.Info("Start removing vector")
// Remove indexed 400 vectors from vald cluster.
for i := range ids[:insertCount] {
if i%10 == 0 {
glg.Infof("Removed: %d", i+10)
}
// Call `Remove` function of Vald client.
// Sends id to server via gRPC.
_, err := client.Remove(ctx, &payload.Remove_Request{
Expand All @@ -145,6 +142,9 @@ func main() {
if err != nil {
glg.Fatal(err)
}
if i%10 == 0 {
glg.Infof("Removed: %d", i+10)
}
}
glg.Info("Finish removing vector")
}
Expand Down

0 comments on commit 1a89537

Please sign in to comment.