milvus

package
v0.7.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CallsBatchSize          = 10000
	DumpBatchSize           = 10000
	MilvusConnectionTimeout = 5 * time.Second
	MilvusConnectionRetries = 40
	MaxSearchRetrievalCount = 16384
)

Global variables

Functions

func CreateCollection

func CreateCollection(schema *entity.Schema, milvusClient client.Client) (funcError error)

CreateCollection creates a collection in the Milvus DB.

Parameters:

  • schema: Schema of the collection to be created.
  • milvusClient: Milvus client.

Returns:

  • error: Error if any issue occurs during creating the collection.

func CreateCustomSchema

func CreateCustomSchema(collectionName string, fields []SchemaField, description string) (*entity.Schema, error)

CreateCustomSchema function to generate a Milvus schema based on user input

func CreateIndexes

func CreateIndexes(collectionName string, milvusClient client.Client, guidFieldName string, denseVectorFieldName string, sparseVectorFieldName string) (funcError error)

CreateIndexes creates indexes for the Milvus DB. Firstly, a scalar index is created for the guid field. Secondly, a vector index is created for the embeddings field.

Parameters:

  • collectionName: Name of the collection to create the indexes for.
  • milvusClient: Milvus client.

Returns:

  • error: Error if any issue occurs during creating the indexes.

func Initialize

func Initialize() (milvusClient client.Client, funcError error)

Initialize initializes the Milvus DB. The function first creates a Milvus client, then creates a collection with the specified name, creates indexes on the collection, and loads the collection.

Parameters:

  • collectionName: Name of the collection to be initialized.

Returns:

  • error: Error if any issue occurs during initializing the Milvus DB.

func InsertData

func InsertData(collectionName string, dataToSend []interface{}) (funcError error)

InsertData sends data to the Milvus DB in order to populate the vector database. The function sends the data in batches of const "CallsBatchSize" entries. The data is sent via HTTP POST requests.

Parameters:

  • collectionName: Name of the collection to send the data to.
  • dataToSend: Data to be sent to the Milvus DB.

Returns:

  • error: Error if any issue occurs during sending the data to the Milvus DB.

Types

type AutoIdFlex

type AutoIdFlex int64

type MilvusInsertData

type MilvusInsertData struct {
	InsertCount int `json:"insertCount"`
}

type MilvusInsertResponse

type MilvusInsertResponse struct {
	Code       int              `json:"code"`
	Message    string           `json:"message"`
	InsertData MilvusInsertData `json:"data"`
}

type MilvusQueryResponse

type MilvusQueryResponse struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Data    []interface{} `json:"data"`
}

type MilvusRequest

type MilvusRequest struct {
	// Common fields
	CollectionName string `json:"collectionName"`

	// Insert request
	Data []interface{} `json:"data,omitempty"`

	// Search and Query request
	OutputFields []string `json:"outputFields,omitempty"`
	Filter       *string  `json:"filter,omitempty"`
	Limit        *int     `json:"limit,omitempty"`
	Offset       *int     `json:"offset,omitempty"`

	// Search request
	DenseVector  []float32        `json:"dense_vector,omitempty"`
	SparseVector map[uint]float32 `json:"sparse_vector,omitempty"`

	// Delete entry request
	AutoIds []AutoIdFlex `json:"id,omitempty"`
}

type MilvusSearchResponse

type MilvusSearchResponse struct {
	Code       int           `json:"code"`
	Message    string        `json:"message"`
	SearchData []interface{} `json:"data"`
}

type SchemaField

type SchemaField struct {
	Name        string
	Type        string
	PrimaryKey  bool
	AutoID      bool
	Dimension   int
	Description string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL