From c899aaa2a74735f0315286c3b37ee257e39b9d5f Mon Sep 17 00:00:00 2001 From: Anush008 Date: Mon, 2 Sep 2024 12:59:25 +0530 Subject: [PATCH 1/2] docs: Improved docstrings --- qdrant/client.go | 2 +- qdrant/collections.go | 133 +++++++++++++++++++++++++++---- qdrant/conditions.go | 53 ++++++++++++- qdrant/oneof_factory.go | 29 ++++--- qdrant/points.go | 171 ++++++++++++++++++++++++++++++++++++---- qdrant/snapshots.go | 54 +++++++++++++ 6 files changed, 393 insertions(+), 49 deletions(-) diff --git a/qdrant/client.go b/qdrant/client.go index 3b07738..f743562 100644 --- a/qdrant/client.go +++ b/qdrant/client.go @@ -58,7 +58,7 @@ func (c *Client) GetSnapshotsClient() SnapshotsClient { return c.GetGrpcClient().Snapshots() } -// Get the low-level client for the qdrant gRPC service. +// Get the low-level client for the Qdrant gRPC service. // https://github.com/qdrant/qdrant/blob/master/lib/api/src/grpc/proto/qdrant.proto func (c *Client) GetQdrantClient() QdrantClient { return c.GetGrpcClient().Qdrant() diff --git a/qdrant/collections.go b/qdrant/collections.go index 1ddf604..c62da09 100644 --- a/qdrant/collections.go +++ b/qdrant/collections.go @@ -4,7 +4,15 @@ import ( "context" ) -// Check the existence of a collection. +// Checks the existence of a collection. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to check. +// +// Returns: +// - bool: True if the collection exists, false otherwise. +// - error: An error if the operation fails. func (c *Client) CollectionExists(ctx context.Context, collectionName string) (bool, error) { resp, err := c.GetCollectionsClient().CollectionExists(ctx, &CollectionExistsRequest{ CollectionName: collectionName, @@ -15,7 +23,15 @@ func (c *Client) CollectionExists(ctx context.Context, collectionName string) (b return resp.GetResult().GetExists(), nil } -// Get detailed information about specified existing collection. +// Retrieves detailed information about a specified existing collection. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to retrieve information for. +// +// Returns: +// - *CollectionInfo: Detailed information about the collection. +// - error: An error if the operation fails. func (c *Client) GetCollection(ctx context.Context, collectionName string) (*CollectionInfo, error) { resp, err := c.GetCollectionsClient().Get(ctx, &GetCollectionInfoRequest{ CollectionName: collectionName, @@ -26,7 +42,14 @@ func (c *Client) GetCollection(ctx context.Context, collectionName string) (*Col return resp.GetResult(), nil } -// Get names of all existing collections. +// Retrieves the names of all existing collections. +// +// Parameters: +// - ctx: The context for the request. +// +// Returns: +// - []string: A slice of collection names. +// - error: An error if the operation fails. func (c *Client) ListCollections(ctx context.Context) ([]string, error) { resp, err := c.GetCollectionsClient().List(ctx, &ListCollectionsRequest{}) if err != nil { @@ -39,7 +62,14 @@ func (c *Client) ListCollections(ctx context.Context) ([]string, error) { return collections, nil } -// Create new collection with given parameters. +// Creates a new collection with the given parameters. +// +// Parameters: +// - ctx: The context for the request. +// - request: The CreateCollection request containing collection parameters. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) CreateCollection(ctx context.Context, request *CreateCollection) error { _, err := c.GetCollectionsClient().Create(ctx, request) if err != nil { @@ -48,7 +78,14 @@ func (c *Client) CreateCollection(ctx context.Context, request *CreateCollection return nil } -// Update parameters of the existing collection. +// Updates parameters of an existing collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The UpdateCollection request containing updated parameters. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) UpdateCollection(ctx context.Context, request *UpdateCollection) error { _, err := c.GetCollectionsClient().Update(ctx, request) if err != nil { @@ -57,7 +94,14 @@ func (c *Client) UpdateCollection(ctx context.Context, request *UpdateCollection return nil } -// Drop collection and all associated data. +// Drops a collection and all associated data. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to delete. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) DeleteCollection(ctx context.Context, collectionName string) error { _, err := c.GetCollectionsClient().Delete(ctx, &DeleteCollection{ CollectionName: collectionName, @@ -68,7 +112,15 @@ func (c *Client) DeleteCollection(ctx context.Context, collectionName string) er return nil } -// Create an alias for a collection. +// Creates an alias for a collection. +// +// Parameters: +// - ctx: The context for the request. +// - aliasName: The name of the alias to create. +// - collectionName: The name of the collection to alias. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) CreateAlias(ctx context.Context, aliasName, collectionName string) error { _, err := c.GetCollectionsClient().UpdateAliases(ctx, &ChangeAliases{ Actions: []*AliasOperations{ @@ -88,7 +140,14 @@ func (c *Client) CreateAlias(ctx context.Context, aliasName, collectionName stri return nil } -// Delete an alias. +// Deletes an alias. +// +// Parameters: +// - ctx: The context for the request. +// - aliasName: The name of the alias to delete. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) DeleteAlias(ctx context.Context, aliasName string) error { _, err := c.GetCollectionsClient().UpdateAliases(ctx, &ChangeAliases{ Actions: []*AliasOperations{ @@ -107,7 +166,15 @@ func (c *Client) DeleteAlias(ctx context.Context, aliasName string) error { return nil } -// Rename an alias. +// Renames an alias. +// +// Parameters: +// - ctx: The context for the request. +// - oldAliasName: The current name of the alias. +// - newAliasName: The new name for the alias. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) RenameAlias(ctx context.Context, oldAliasName, newAliasName string) error { _, err := c.GetCollectionsClient().UpdateAliases(ctx, &ChangeAliases{ Actions: []*AliasOperations{ @@ -127,7 +194,15 @@ func (c *Client) RenameAlias(ctx context.Context, oldAliasName, newAliasName str return nil } -// List all aliases for a collection. +// Lists all aliases for a collection. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to list aliases for. +// +// Returns: +// - []string: A slice of alias names. +// - error: An error if the operation fails. func (c *Client) ListCollectionAliases(ctx context.Context, collectionName string) ([]string, error) { resp, err := c.GetCollectionsClient().ListCollectionAliases(ctx, &ListCollectionAliasesRequest{ CollectionName: collectionName, @@ -142,7 +217,14 @@ func (c *Client) ListCollectionAliases(ctx context.Context, collectionName strin return aliases, nil } -// List all aliases. +// Lists all aliases. +// +// Parameters: +// - ctx: The context for the request. +// +// Returns: +// - []*AliasDescription: A slice of AliasDescription objects. +// - error: An error if the operation fails. func (c *Client) ListAliases(ctx context.Context) ([]*AliasDescription, error) { resp, err := c.GetCollectionsClient().ListAliases(ctx, &ListAliasesRequest{}) if err != nil { @@ -151,7 +233,14 @@ func (c *Client) ListAliases(ctx context.Context) ([]*AliasDescription, error) { return resp.GetAliases(), nil } -// Update aliases. +// Updates aliases. +// +// Parameters: +// - ctx: The context for the request. +// - actions: A slice of AliasOperations to perform. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) UpdateAliases(ctx context.Context, actions []*AliasOperations) error { _, err := c.GetCollectionsClient().UpdateAliases(ctx, &ChangeAliases{ Actions: actions, @@ -162,7 +251,15 @@ func (c *Client) UpdateAliases(ctx context.Context, actions []*AliasOperations) return nil } -// Create a shard key for a collection. +// Creates a shard key for a collection. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to create a shard key for. +// - request: The CreateShardKey request containing shard key parameters. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) CreateShardKey(ctx context.Context, collectionName string, request *CreateShardKey) error { _, err := c.GetCollectionsClient().CreateShardKey(ctx, &CreateShardKeyRequest{ CollectionName: collectionName, @@ -174,7 +271,15 @@ func (c *Client) CreateShardKey(ctx context.Context, collectionName string, requ return nil } -// Delete a shard key for a collection. +// Deletes a shard key for a collection. +// +// Parameters: +// - ctx: The context for the request. +// - collectionName: The name of the collection to delete a shard key from. +// - request: The DeleteShardKey request containing shard key parameters. +// +// Returns: +// - error: An error if the operation fails. func (c *Client) DeleteShardKey(ctx context.Context, collectionName string, request *DeleteShardKey) error { _, err := c.GetCollectionsClient().DeleteShardKey(ctx, &DeleteShardKeyRequest{ CollectionName: collectionName, diff --git a/qdrant/conditions.go b/qdrant/conditions.go index a514eef..fcaa0c0 100644 --- a/qdrant/conditions.go +++ b/qdrant/conditions.go @@ -2,7 +2,15 @@ // https://qdrant.tech/documentation/concepts/filtering/#filtering-conditions package qdrant -// TODO: please add comments to all filters below +// Creates a condition that matches an exact keyword in a specified field. +// This is an alias for NewMatchKeyword(). +// See: https://qdrant.tech/documentation/concepts/filtering/#match +func NewMatch(field, keyword string) *Condition { + return NewMatchKeyword(field, keyword) +} + +// Creates a condition that matches an exact keyword in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match func NewMatchKeyword(field, keyword string) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -16,6 +24,9 @@ func NewMatchKeyword(field, keyword string) *Condition { } } +// Creates a condition to match a specific substring, token or phrase. +// Exact texts that will match the condition depend on full-text index configuration. +// See: https://qdrant.tech/documentation/concepts/filtering/#full-text-match func NewMatchText(field, text string) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -29,6 +40,8 @@ func NewMatchText(field, text string) *Condition { } } +// Creates a condition that matches a boolean value in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match func NewMatchBool(field string, value bool) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -42,6 +55,8 @@ func NewMatchBool(field string, value bool) *Condition { } } +// Creates a condition that matches an integer value in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match func NewMatchInt(field string, value int64) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -55,6 +70,8 @@ func NewMatchInt(field string, value int64) *Condition { } } +// Creates a condition that matches any of the given keywords in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match-any func NewMatchKeywords(field string, keywords ...string) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -70,6 +87,8 @@ func NewMatchKeywords(field string, keywords ...string) *Condition { } } +// Creates a condition that matches any of the given integer values in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match-any func NewMatchInts(field string, values ...int64) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -85,11 +104,15 @@ func NewMatchInts(field string, values ...int64) *Condition { } } -// Same as NewMatchExceptKeywords. +// Creates a condition that matches any value except the given keywords in a specified field. +// This is an alias for NewMatchExceptKeywords. +// See: https://qdrant.tech/documentation/concepts/filtering/#match-except func NewMatchExcept(field string, keywords ...string) *Condition { return NewMatchExceptKeywords(field, keywords...) } +// Creates a condition that matches any value except the given keywords in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match-except func NewMatchExceptKeywords(field string, keywords ...string) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -105,6 +128,8 @@ func NewMatchExceptKeywords(field string, keywords ...string) *Condition { } } +// Creates a condition that matches any value except the given integer values in a specified field. +// See: https://qdrant.tech/documentation/concepts/filtering/#match-except func NewMatchExceptInts(field string, values ...int64) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -120,6 +145,8 @@ func NewMatchExceptInts(field string, values ...int64) *Condition { } } +// Creates a condition that checks if a specified field is null. +// See: https://qdrant.tech/documentation/concepts/filtering/#is-null func NewIsNull(field string) *Condition { return &Condition{ ConditionOneOf: &Condition_IsNull{ @@ -130,6 +157,8 @@ func NewIsNull(field string) *Condition { } } +// Creates a condition that checks if a specified field is empty. +// See: https://qdrant.tech/documentation/concepts/filtering/#is-empty func NewIsEmpty(field string) *Condition { return &Condition{ ConditionOneOf: &Condition_IsEmpty{ @@ -140,6 +169,8 @@ func NewIsEmpty(field string) *Condition { } } +// Creates a condition that checks if a point has any of the specified IDs. +// See: https://qdrant.tech/documentation/concepts/filtering/#has-id func NewHasID(ids ...*PointId) *Condition { return &Condition{ ConditionOneOf: &Condition_HasId{ @@ -150,6 +181,8 @@ func NewHasID(ids ...*PointId) *Condition { } } +// Creates a nested condition for filtering on nested fields. +// See: https://qdrant.tech/documentation/concepts/filtering/#nested func NewNestedCondtion(field string, conditon *Condition) *Condition { filter := &Filter{ Must: []*Condition{conditon}, @@ -165,6 +198,8 @@ func NewNestedCondtion(field string, conditon *Condition) *Condition { } } +// Creates a nested filter for filtering on nested fields. +// See: https://qdrant.tech/documentation/concepts/filtering/#nested func NewNestedFilter(field string, filter *Filter) *Condition { return &Condition{ ConditionOneOf: &Condition_Nested{ @@ -176,6 +211,8 @@ func NewNestedFilter(field string, filter *Filter) *Condition { } } +// Creates a condition from a filter. +// This is useful for creating complex nested conditions. func NewFilterAsCondition(filter *Filter) *Condition { return &Condition{ ConditionOneOf: &Condition_Filter{ @@ -184,6 +221,8 @@ func NewFilterAsCondition(filter *Filter) *Condition { } } +// Creates a range condition for numeric or date fields. +// See: https://qdrant.tech/documentation/concepts/filtering/#range func NewRange(field string, rangeVal *Range) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -195,6 +234,8 @@ func NewRange(field string, rangeVal *Range) *Condition { } } +// Creates a geo filter condition that matches points within a specified radius from a center point. +// See: https://qdrant.tech/documentation/concepts/filtering/#geo-radius func NewGeoRadius(field string, lat, long float64, radius float32) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -212,6 +253,8 @@ func NewGeoRadius(field string, lat, long float64, radius float32) *Condition { } } +// Creates a geo filter condition that matches points within a specified bounding box. +// See: https://qdrant.tech/documentation/concepts/filtering/#geo-bounding-box func NewGeoBoundingBox(field string, topLeftLat, topLeftLon, bottomRightLat, bottomRightLon float64) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -232,6 +275,8 @@ func NewGeoBoundingBox(field string, topLeftLat, topLeftLon, bottomRightLat, bot } } +// Creates a geo filter condition that matches points within a specified polygon. +// See: https://qdrant.tech/documentation/concepts/filtering/#geo-polygon func NewGeoPolygon(field string, exterior *GeoLineString, interior ...*GeoLineString) *Condition { geoPolygon := &GeoPolygon{ Exterior: exterior, @@ -248,6 +293,8 @@ func NewGeoPolygon(field string, exterior *GeoLineString, interior ...*GeoLineSt } } +// Creates a condition that filters based on the number of values in an array field. +// See: https://qdrant.tech/documentation/concepts/filtering/#values-count func NewValuesCount(field string, valuesCount *ValuesCount) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ @@ -259,6 +306,8 @@ func NewValuesCount(field string, valuesCount *ValuesCount) *Condition { } } +// Creates a condition that filters based on a datetime range. +// See: https://qdrant.tech/documentation/concepts/filtering/#datetime-range func NewDatetimeRange(field string, dateTimeRange *DatetimeRange) *Condition { return &Condition{ ConditionOneOf: &Condition_Field{ diff --git a/qdrant/oneof_factory.go b/qdrant/oneof_factory.go index a3f9db8..cbc9b16 100644 --- a/qdrant/oneof_factory.go +++ b/qdrant/oneof_factory.go @@ -116,7 +116,7 @@ func NewQuantizationDiffDisabled() *QuantizationConfigDiff { } // Creates a *PayloadIndexParams instance from *KeywordIndexParams. -// Same as NewPayloadIndexParamsKeyword(). +// This is an alias for NewPayloadIndexParamsKeyword(). func NewPayloadIndexParams(params *KeywordIndexParams) *PayloadIndexParams { return NewPayloadIndexParamsKeyword(params) } @@ -194,7 +194,7 @@ func NewPayloadIndexParamsUUID(params *UuidIndexParams) *PayloadIndexParams { } // Creates an *AliasOperations instance to create an alias. -// Same as NewAliasCreate(). +// This is an alias for NewAliasCreate(). func NewAlias(aliasName, collectionName string) *AliasOperations { return NewAliasCreate(aliasName, collectionName) } @@ -235,7 +235,7 @@ func NewAliasDelete(aliasName string) *AliasOperations { } // Creates a *ShardKey instance from a string. -// Same as NewShardKeyKeyword(). +// This is an alias for NewShardKeyKeyword(). func NewShardKey(key string) *ShardKey { return NewShardKeyKeyword(key) } @@ -259,7 +259,7 @@ func NewShardKeyNum(key uint64) *ShardKey { } // Creates a *ReadConsistency instance from a ReadConsistencyType. -// Same as NewReadConsistencyType(). +// This is an alias for NewReadConsistencyType(). func NewReadConsistency(readConsistencyType ReadConsistencyType) *ReadConsistency { return NewReadConsistencyType(readConsistencyType) } @@ -283,7 +283,7 @@ func NewReadConsistencyFactor(readConsistencyFactor uint64) *ReadConsistency { } // Creates a *PointId instance from a UUID string. -// Same as NewPointIDUUID(). +// This is an alias for NewPointIDUUID(). func NewPointID(uuid string) *PointId { return NewPointIDUUID(uuid) } @@ -307,7 +307,7 @@ func NewPointIDNum(num uint64) *PointId { } // Creates a *VectorInput instance for dense vectors. -// Same as NewVectorInputDense(). +// This is an alias for NewVectorInputDense(). func NewVectorInput(values ...float32) *VectorInput { return NewVectorInputDense(values) } @@ -362,7 +362,7 @@ func NewVectorInputMulti(vectors [][]float32) *VectorInput { } // Creates a *WithPayloadSelector instance with payload enabled/disabled. -// Same as NewWithPayloadEnable(). +// This is an alias for NewWithPayloadEnable(). func NewWithPayload(enable bool) *WithPayloadSelector { return NewWithPayloadEnable(enable) } @@ -399,7 +399,7 @@ func NewWithPayloadExclude(exclude ...string) *WithPayloadSelector { } // Creates a *WithVectorsSelector instance with vectors enabled/disabled. -// Same as NewWithVectorsEnable(). +// This is an alias for NewWithVectorsEnable(). func NewWithVectors(enable bool) *WithVectorsSelector { return NewWithVectorsEnable(enable) } @@ -425,7 +425,7 @@ func NewWithVectorsInclude(names ...string) *WithVectorsSelector { } // Creates a *Vectors instance for dense vectors. -// Same as NewVectorsDense(). +// This is an alias for NewVectorsDense(). func NewVectors(values ...float32) *Vectors { return NewVectorsDense(values) } @@ -469,7 +469,7 @@ func NewVectorsMap(vectors map[string]*Vector) *Vectors { } // Creates a *Vector instance for dense vectors. -// Same as NewVectorDense(). +// This is an alias for NewVectorDense(). func NewVector(values ...float32) *Vector { return NewVectorDense(values) } @@ -541,8 +541,7 @@ func NewStartFromTimestamp(seconds int64, nanos int32) *StartFrom { } } -// Creates a *StartFrom instance for a datetime string. -// TODO: please specify the format of the string, like RFC3339 +// Creates a *StartFrom instance for a datetime string in the RFC3339 format. func NewStartFromDatetime(value string) *StartFrom { return &StartFrom{ Value: &StartFrom_Datetime{ @@ -552,7 +551,7 @@ func NewStartFromDatetime(value string) *StartFrom { } // Creates a *TargetVector instance from a *Vector. -// Same as NewTargetVector(). +// This is an alias for NewTargetVector(). func NewTarget(vector *Vector) *TargetVector { return NewTargetVector(vector) } @@ -593,7 +592,7 @@ func NewQueryNearest(nearest *VectorInput) *Query { } // Creates a *Query instance for a nearest query from dense vectors. -// Same as NewQueryDense(). +// This is an alias for NewQueryDense(). func NewQuery(values ...float32) *Query { return NewQueryDense(values) } @@ -799,7 +798,7 @@ func NewGroupIDString(value string) *GroupId { } // Creates a *PointsSelector instance for selecting points by IDs. -// Same as NewPointsSelectorIDs(). +// This is an alias for NewPointsSelectorIDs(). func NewPointsSelector(ids ...*PointId) *PointsSelector { return NewPointsSelectorIDs(ids) } diff --git a/qdrant/points.go b/qdrant/points.go index 53dc82a..540e2b6 100644 --- a/qdrant/points.go +++ b/qdrant/points.go @@ -4,7 +4,15 @@ import ( "context" ) -// Perform insert + updates on points. If a point with a given ID already exists - it will be overwritten. +// Performs insert + updates on points. If a point with a given ID already exists, it will be overwritten. +// +// Parameters: +// - ctx: The context for the request. +// - request: The UpsertPoints request containing the points to upsert. +// +// Returns: +// - *UpdateResult: The result of the upsert operation. +// - error: An error if the operation fails. func (c *Client) Upsert(ctx context.Context, request *UpsertPoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().Upsert(ctx, request) if err != nil { @@ -13,7 +21,15 @@ func (c *Client) Upsert(ctx context.Context, request *UpsertPoints) (*UpdateResu return resp.GetResult(), nil } -// Delete points from a collection by IDs or payload filters. +// Removes points from a collection by IDs or payload filters. +// +// Parameters: +// - ctx: The context for the request. +// - request: The DeletePoints request specifying which points to delete. +// +// Returns: +// - *UpdateResult: The result of the delete operation. +// - error: An error if the operation fails. func (c *Client) Delete(ctx context.Context, request *DeletePoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().Delete(ctx, request) if err != nil { @@ -22,7 +38,15 @@ func (c *Client) Delete(ctx context.Context, request *DeletePoints) (*UpdateResu return resp.GetResult(), nil } -// Get points from a collection by IDs. +// Retrieves points from a collection by IDs. +// +// Parameters: +// - ctx: The context for the request. +// - request: The GetPoints request specifying which points to retrieve. +// +// Returns: +// - []*RetrievedPoint: A slice of retrieved points. +// - error: An error if the operation fails. func (c *Client) Get(ctx context.Context, request *GetPoints) ([]*RetrievedPoint, error) { resp, err := c.GetPointsClient().Get(ctx, request) if err != nil { @@ -31,7 +55,15 @@ func (c *Client) Get(ctx context.Context, request *GetPoints) ([]*RetrievedPoint return resp.GetResult(), nil } -// Iterate over all or filtered points in a collection. +// Iterates over all or filtered points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The ScrollPoints request specifying the scroll parameters. +// +// Returns: +// - []*RetrievedPoint: A slice of retrieved points. +// - error: An error if the operation fails. func (c *Client) Scroll(ctx context.Context, request *ScrollPoints) ([]*RetrievedPoint, error) { resp, err := c.GetPointsClient().Scroll(ctx, request) if err != nil { @@ -40,7 +72,15 @@ func (c *Client) Scroll(ctx context.Context, request *ScrollPoints) ([]*Retrieve return resp.GetResult(), nil } -// Update vectors for points in a collection. +// Updates vectors for points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The UpdatePointVectors request containing the vectors to update. +// +// Returns: +// - *UpdateResult: The result of the update operation. +// - error: An error if the operation fails. func (c *Client) UpdateVectors(ctx context.Context, request *UpdatePointVectors) (*UpdateResult, error) { resp, err := c.GetPointsClient().UpdateVectors(ctx, request) if err != nil { @@ -49,7 +89,15 @@ func (c *Client) UpdateVectors(ctx context.Context, request *UpdatePointVectors) return resp.GetResult(), nil } -// Delete vectors from points in a collection. +// Removes vectors from points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The DeletePointVectors request specifying which vectors to delete. +// +// Returns: +// - *UpdateResult: The result of the delete operation. +// - error: An error if the operation fails. func (c *Client) DeleteVectors(ctx context.Context, request *DeletePointVectors) (*UpdateResult, error) { resp, err := c.GetPointsClient().DeleteVectors(ctx, request) if err != nil { @@ -58,7 +106,16 @@ func (c *Client) DeleteVectors(ctx context.Context, request *DeletePointVectors) return resp.GetResult(), nil } -// Set payload fields for points in a collection. +// Sets payload fields for points in a collection. +// Can be used to add new payload fields or update existing ones. +// +// Parameters: +// - ctx: The context for the request. +// - request: The SetPayloadPoints request containing the payload to set. +// +// Returns: +// - *UpdateResult: The result of the set operation. +// - error: An error if the operation fails. func (c *Client) SetPayload(ctx context.Context, request *SetPayloadPoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().SetPayload(ctx, request) if err != nil { @@ -67,7 +124,15 @@ func (c *Client) SetPayload(ctx context.Context, request *SetPayloadPoints) (*Up return resp.GetResult(), nil } -// Overwrite payload for points in a collection. +// Overwrites the entire payload for points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The SetPayloadPoints request containing the payload to overwrite. +// +// Returns: +// - *UpdateResult: The result of the overwrite operation. +// - error: An error if the operation fails. func (c *Client) OverwritePayload(ctx context.Context, request *SetPayloadPoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().OverwritePayload(ctx, request) if err != nil { @@ -76,7 +141,15 @@ func (c *Client) OverwritePayload(ctx context.Context, request *SetPayloadPoints return resp.GetResult(), nil } -// Delete payload fields from points in a collection. +// Removes payload fields from points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The DeletePayloadPoints request specifying which payload fields to delete. +// +// Returns: +// - *UpdateResult: The result of the delete operation. +// - error: An error if the operation fails. func (c *Client) DeletePayload(ctx context.Context, request *DeletePayloadPoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().DeletePayload(ctx, request) if err != nil { @@ -85,7 +158,15 @@ func (c *Client) DeletePayload(ctx context.Context, request *DeletePayloadPoints return resp.GetResult(), nil } -// Clear payload fields for points in a collection. +// Removes all payload fields from points in a collection. +// +// Parameters: +// - ctx: The context for the request. +// - request: The ClearPayloadPoints request specifying which points to clear. +// +// Returns: +// - *UpdateResult: The result of the clear operation. +// - error: An error if the operation fails. func (c *Client) ClearPayload(ctx context.Context, request *ClearPayloadPoints) (*UpdateResult, error) { resp, err := c.GetPointsClient().ClearPayload(ctx, request) if err != nil { @@ -94,7 +175,15 @@ func (c *Client) ClearPayload(ctx context.Context, request *ClearPayloadPoints) return resp.GetResult(), nil } -// Create index for a payload field. +// Creates an index for a payload field. +// +// Parameters: +// - ctx: The context for the request. +// - request: The CreateFieldIndexCollection request specifying the field to index. +// +// Returns: +// - *UpdateResult: The result of the index creation operation. +// - error: An error if the operation fails. func (c *Client) CreateFieldIndex(ctx context.Context, request *CreateFieldIndexCollection) (*UpdateResult, error) { resp, err := c.GetPointsClient().CreateFieldIndex(ctx, request) if err != nil { @@ -103,7 +192,15 @@ func (c *Client) CreateFieldIndex(ctx context.Context, request *CreateFieldIndex return resp.GetResult(), nil } -// Delete index for a payload field. +// Removes an index for a payload field. +// +// Parameters: +// - ctx: The context for the request. +// - request: The DeleteFieldIndexCollection request specifying the field index to delete. +// +// Returns: +// - *UpdateResult: The result of the index deletion operation. +// - error: An error if the operation fails. func (c *Client) DeleteFieldIndex(ctx context.Context, request *DeleteFieldIndexCollection) (*UpdateResult, error) { resp, err := c.GetPointsClient().DeleteFieldIndex(ctx, request) if err != nil { @@ -112,8 +209,16 @@ func (c *Client) DeleteFieldIndex(ctx context.Context, request *DeleteFieldIndex return resp.GetResult(), nil } -// Count points in collection with given filtering conditions. +// Returns the number of points in a collection with given filtering conditions. // Gets the total count if no filter is provided. +// +// Parameters: +// - ctx: The context for the request. +// - request: The CountPoints request containing optional filtering conditions. +// +// Returns: +// - uint64: The count of points matching the conditions. +// - error: An error if the operation fails. func (c *Client) Count(ctx context.Context, request *CountPoints) (uint64, error) { resp, err := c.GetPointsClient().Count(ctx, request) if err != nil { @@ -122,7 +227,15 @@ func (c *Client) Count(ctx context.Context, request *CountPoints) (uint64, error return resp.GetResult().GetCount(), nil } -// Perform multiple update operations in one request. +// Performs multiple update operations in one request. +// +// Parameters: +// - ctx: The context for the request. +// - request: The UpdateBatchPoints request containing multiple update operations. +// +// Returns: +// - []*UpdateResult: A slice of results for each update operation. +// - error: An error if the operation fails. func (c *Client) UpdateBatch(ctx context.Context, request *UpdateBatchPoints) ([]*UpdateResult, error) { resp, err := c.GetPointsClient().UpdateBatch(ctx, request) if err != nil { @@ -131,9 +244,17 @@ func (c *Client) UpdateBatch(ctx context.Context, request *UpdateBatchPoints) ([ return resp.GetResult(), nil } -// Universally query points. +// Performs a universal query on points. // Covers all capabilities of search, recommend, discover, filters. // Also enables hybrid and multi-stage queries. +// +// Parameters: +// - ctx: The context for the request. +// - request: The QueryPoints request containing the query parameters. +// +// Returns: +// - []*ScoredPoint: A slice of scored points matching the query. +// - error: An error if the operation fails. func (c *Client) Query(ctx context.Context, request *QueryPoints) ([]*ScoredPoint, error) { resp, err := c.GetPointsClient().Query(ctx, request) if err != nil { @@ -142,9 +263,17 @@ func (c *Client) Query(ctx context.Context, request *QueryPoints) ([]*ScoredPoin return resp.GetResult(), nil } -// Universally query points in a batch. +// Pperforms multiple universal queries on points in a batch. // Covers all capabilities of search, recommend, discover, filters. // Also enables hybrid and multi-stage queries. +// +// Parameters: +// - ctx: The context for the request. +// - request: The QueryBatchPoints request containing multiple query parameters. +// +// Returns: +// - []*BatchResult: A slice of batch results for each query. +// - error: An error if the operation fails. func (c *Client) QueryBatch(ctx context.Context, request *QueryBatchPoints) ([]*BatchResult, error) { resp, err := c.GetPointsClient().QueryBatch(ctx, request) if err != nil { @@ -153,9 +282,17 @@ func (c *Client) QueryBatch(ctx context.Context, request *QueryBatchPoints) ([]* return resp.GetResult(), nil } -// Universally query points grouped by a payload field. +// Performs a universal query on points grouped by a payload field. // Covers all capabilities of search, recommend, discover, filters. // Also enables hybrid and multi-stage queries. +// +// Parameters: +// - ctx: The context for the request. +// - request: The QueryPointGroups request containing the query parameters. +// +// Returns: +// - []*PointGroup: A slice of point groups matching the query. +// - error: An error if the operation fails. func (c *Client) QueryGroups(ctx context.Context, request *QueryPointGroups) ([]*PointGroup, error) { resp, err := c.GetPointsClient().QueryGroups(ctx, request) if err != nil { diff --git a/qdrant/snapshots.go b/qdrant/snapshots.go index 0b77bc5..a9ec7f7 100644 --- a/qdrant/snapshots.go +++ b/qdrant/snapshots.go @@ -4,6 +4,17 @@ import ( "context" ) +// Creates a snapshot of a specific collection. +// Snapshots are read-only copies of the collection data, which can be used for backup and restore purposes. +// The snapshot is created asynchronously and does not block the collection usage. +// +// Parameters: +// - ctx: The context for the request +// - collection: The name of the collection to create a snapshot for +// +// Returns: +// - *SnapshotDescription: Description of the created snapshot +// - error: Any error encountered during the snapshot creation func (c *Client) CreateSnapshot(ctx context.Context, collection string) (*SnapshotDescription, error) { resp, err := c.GetSnapshotsClient().Create(ctx, &CreateSnapshotRequest{ CollectionName: collection, @@ -14,6 +25,15 @@ func (c *Client) CreateSnapshot(ctx context.Context, collection string) (*Snapsh return resp.GetSnapshotDescription(), nil } +// Retrieves a list of all snapshots for a specific collection. +// +// Parameters: +// - ctx: The context for the request +// - collection: The name of the collection to list snapshots for +// +// Returns: +// - []*SnapshotDescription: A slice of snapshot descriptions +// - error: Any error encountered while listing snapshots func (c *Client) ListSnapshots(ctx context.Context, collection string) ([]*SnapshotDescription, error) { resp, err := c.GetSnapshotsClient().List(ctx, &ListSnapshotsRequest{ CollectionName: collection, @@ -24,6 +44,15 @@ func (c *Client) ListSnapshots(ctx context.Context, collection string) ([]*Snaps return resp.GetSnapshotDescriptions(), nil } +// Removes a specific snapshot of a collection. +// +// Parameters: +// - ctx: The context for the request +// - collection: The name of the collection the snapshot belongs to +// - snapshot: The name of the snapshot to delete +// +// Returns: +// - error: Any error encountered while deleting the snapshot func (c *Client) DeleteSnapshot(ctx context.Context, collection string, snapshot string) error { _, err := c.GetSnapshotsClient().Delete(ctx, &DeleteSnapshotRequest{ CollectionName: collection, @@ -35,6 +64,15 @@ func (c *Client) DeleteSnapshot(ctx context.Context, collection string, snapshot return nil } +// Creates a snapshot of the entire storage, including all collections. +// This operation is useful for creating full backups of the Qdrant instance. +// +// Parameters: +// - ctx: The context for the request +// +// Returns: +// - *SnapshotDescription: Description of the created full snapshot +// - error: Any error encountered during the full snapshot creation func (c *Client) CreateFullSnapshot(ctx context.Context) (*SnapshotDescription, error) { resp, err := c.GetSnapshotsClient().CreateFull(ctx, &CreateFullSnapshotRequest{}) if err != nil { @@ -43,6 +81,14 @@ func (c *Client) CreateFullSnapshot(ctx context.Context) (*SnapshotDescription, return resp.GetSnapshotDescription(), nil } +// ListFullSnapshots retrieves a list of all full snapshots of the storage. +// +// Parameters: +// - ctx: The context for the request +// +// Returns: +// - []*SnapshotDescription: A slice of full snapshot descriptions +// - error: Any error encountered while listing full snapshots func (c *Client) ListFullSnapshots(ctx context.Context) ([]*SnapshotDescription, error) { resp, err := c.GetSnapshotsClient().ListFull(ctx, &ListFullSnapshotsRequest{}) if err != nil { @@ -51,6 +97,14 @@ func (c *Client) ListFullSnapshots(ctx context.Context) ([]*SnapshotDescription, return resp.GetSnapshotDescriptions(), nil } +// Removes a specific full snapshot of the storage. +// +// Parameters: +// - ctx: The context for the request +// - snapshot: The name of the full snapshot to delete +// +// Returns: +// - error: Any error encountered while deleting the full snapshot func (c *Client) DeleteFullSnapshot(ctx context.Context, snapshot string) error { _, err := c.GetSnapshotsClient().DeleteFull(ctx, &DeleteFullSnapshotRequest{ SnapshotName: snapshot, From 64eca29cebcb8c53808338df74bf746df8c97067 Mon Sep 17 00:00:00 2001 From: Anush008 Date: Tue, 3 Sep 2024 12:34:53 +0530 Subject: [PATCH 2/2] fix: typos --- qdrant/conditions.go | 2 +- qdrant/points.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qdrant/conditions.go b/qdrant/conditions.go index fcaa0c0..d10da56 100644 --- a/qdrant/conditions.go +++ b/qdrant/conditions.go @@ -183,7 +183,7 @@ func NewHasID(ids ...*PointId) *Condition { // Creates a nested condition for filtering on nested fields. // See: https://qdrant.tech/documentation/concepts/filtering/#nested -func NewNestedCondtion(field string, conditon *Condition) *Condition { +func NewNestedCondition(field string, conditon *Condition) *Condition { filter := &Filter{ Must: []*Condition{conditon}, } diff --git a/qdrant/points.go b/qdrant/points.go index 540e2b6..683c2c0 100644 --- a/qdrant/points.go +++ b/qdrant/points.go @@ -263,7 +263,7 @@ func (c *Client) Query(ctx context.Context, request *QueryPoints) ([]*ScoredPoin return resp.GetResult(), nil } -// Pperforms multiple universal queries on points in a batch. +// Performs multiple universal queries on points in a batch. // Covers all capabilities of search, recommend, discover, filters. // Also enables hybrid and multi-stage queries. //