Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ err := client.AddCollectionField(ctx, option)

The name of the target collection.

- **field** (**[entity.Field](Field.md)*)
- **[field](Field.md)** (**[entity.Field](Field.md)*)

The field.

Expand Down Expand Up @@ -52,10 +52,8 @@ import (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

milvusAddr := "127.0.0.1:19530"

cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
Address: "localhost:19530",
})
if err != nil {
log.Fatal("failed to connect to milvus server: ", err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ err := client.AlterAlias(ctx, option)

**PARAMETERS:**

- **alias** (*string*)
- **[alias](Alias.md)** (*string*)

The alias name to assign.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ err := client.AlterCollectionProperties(ctx, option)

**PARAMETERS:**

- **collection** (*string*)
- **[collection](Collection.md)** (*string*)

The collection.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ err := client.CreateAlias(ctx, option)

The name of the target collection.

- **alias** (*string*)
- **[alias](Alias.md)** (*string*)

The alias name to assign.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ result, err := client.DescribeAlias(ctx, option)

**PARAMETERS:**

- **alias** (*string*)
- **[alias](Alias.md)** (*string*)

The alias name to assign.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ result, err := client.DescribeCollection(ctx, option)

**RETURN TYPE:**

*collection* entity.Collection, err error*
*[collection* ](Collection.md)entity.Collection, err error*

**RETURNS:**

Expand Down
2 changes: 1 addition & 1 deletion API_Reference/milvus-sdk-go/v2.6.x/Collection/DropAlias.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ err := client.DropAlias(ctx, option)

**PARAMETERS:**

- **alias** (*string*)
- **[alias](Alias.md)** (*string*)

The alias name to assign.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ err := client.DropCollectionProperties(ctx, option)

**PARAMETERS:**

- **collection** (*string*)
- **[collection](Collection.md)** (*string*)

The collection.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# TruncateCollection()

This operation removes all data from a collection but retains the collection schema and structure

```go
func (c *Client) TruncateCollection(ctx context.Context, option TruncateCollectionOption, callOptions ...grpc.CallOption) error
```

## Request Syntax

```go
err := client.TruncateCollection(
ctx,
milvusclient.NewTruncateCollectionOption("collection_name")
)
```

**PARAMETERS:**

- **collectionName** (*string*)

The name of the target collection.

**RETURN TYPE:**

*error*

**RETURNS:**

Returns nil on success, or an error describing what went wrong.

**EXCEPTIONS:**

- **error**

Check `err != nil` for failure details.

## Example

```go
package main

import (
"context"
"log"

"github.com/milvus-io/milvus/client/v2/milvusclient"
)

func main() {
ctx := context.Background()

client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "localhost:19530",
})
if err != nil {
log.Fatal(err)
}

// Truncate collection
err = client.TruncateCollection(ctx, milvusclient.NewTruncateCollectionOption("my_collection"))
if err != nil {
log.Printf("Failed to truncate collection: %v", err)
return
}

log.Println("Collection truncated successfully")
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ result, err := client.CreateIndex(ctx, option)

The name of the field.

- **index** (*[index.Index](Index/Index.md)*)
- **[index](Index/Index.md)** (*[index.Index](Index/Index.md)*)

The index.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewAutoIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewBinFlatIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewBinIvfFlatIndex(metricType MetricType, nlist int) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -18,7 +18,7 @@ func NewBinIvfFlatIndex(metricType MetricType, nlist int) Index

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewDiskANNIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewFlatIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewGPUBruteForceIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewGPUCagraIndex(metricType MetricType, intermediateGraphDegree, graphDegre

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -22,7 +22,7 @@ func NewGPUCagraIndex(metricType MetricType, intermediateGraphDegree, graphDegre

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewGPUIVPFlatIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ func NewGPUIVPPQIndex(metricType MetricType) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewGenericIndex(name string, params map[string]string) GenericIndex

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewHNSWIndex(metricType MetricType, m int, efConstruction int) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -22,7 +22,7 @@ func NewHNSWIndex(metricType MetricType, m int, efConstruction int) Index

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewIvfFlatIndex(metricType MetricType, nlist int) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -18,7 +18,7 @@ func NewIvfFlatIndex(metricType MetricType, nlist int) Index

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewIvfPQIndex(metricType MetricType, nlist int, m int, nbits int) Index

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -26,7 +26,7 @@ func NewIvfPQIndex(metricType MetricType, nlist int, m int, nbits int) Index

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewIvfRabitQIndex(metricType MetricType, nlist int) *ivfRabitQIndex

**PARAMETERS:**

- **metricType** (*[MetricType](../MetricType.md)*)
- **[metricType](../MetricType.md)** (*[MetricType](../MetricType.md)*)

The distance metric type for similarity search (e.g., index.COSINE, index.L2, index.IP).

Expand All @@ -18,7 +18,7 @@ func NewIvfRabitQIndex(metricType MetricType, nlist int) *ivfRabitQIndex

**RETURNS:**

*Index*
*[Index](Index.md)*

An index configuration instance. Pass this to `CreateIndex()` via the index option.

Expand Down
Loading