Skip to content

use milvus in comfortable way, even if you know nothing about it.

License

Notifications You must be signed in to change notification settings

doptime/q-milvus

Repository files navigation

q-milvus

q-milvus provides the transparent way to use milvus.

Feature: Auto build schema & Auto build index & Insert Search Remove easily

step1. define you schema like this:

package qmilvus

import (
	"context"
	"github.com/milvus-io/milvus-sdk-go/v2/entity"
	milvus "github.com/yangkequn/q-milvus"
)

type FooEntity struct {
	Id         int64     `schema:"in,out" primarykey:"true"`
	Name       string    `schema:"in,out" max_length:"2048"`
	Vector     []float32 `dim:"384" schema:"in" index:"true"`
	Score      float32   `schema:"out"`
}

//Index: define your index field name and type here. required
func (v FooEntity) Index() (indexFieldName string, index entity.Index) {
	index, _ = entity.NewIndexIvfFlat(entity.IP, 256)
	return "Vector", index
}

var collection *milvus.Collection = milvus.NewCollection[FooEntity]("milvus.lan:19530",  "").Create()

step2. using collection, you can Insert Search or Remove

var models []*FooEntity
// insert operation
err:=collection.Insert(models)
// search operation
ids,scores,models,err:=collection.SearchVector(query []float32,10)
// remove operation. type of ids : []int64
err:=collection.RemoveByKey(ids)

About

use milvus in comfortable way, even if you know nothing about it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages