Class: Milvus::Indexes

Inherits:
Base
  • Object
show all
Defined in:
lib/milvus/indexes.rb

Constant Summary collapse

PATH =
"indexes"

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Milvus::Base

Instance Method Details

#create(collection_name:, index_params:) ⇒ Hash

This creates a named index for a target field, which can either be a vector field or a scalar field.

Parameters:

  • collection_name (String)

    The name of the collection to create the index for.

  • index_params (Hash)

    The parameters for the index.

Returns:

  • (Hash)

    Server response



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/milvus/indexes.rb', line 12

def create(
  collection_name:,
  index_params:
)
  response = client.connection.post("#{PATH}/create") do |req|
    req.body = {
      collectionName: collection_name,
      indexParams: index_params
    }
  end
  response.body.empty? ? true : response.body
end

#describe(collection_name:, index_name:) ⇒ Hash

This operation describes the current index.

Parameters:

  • collection_name (String)

    The name of the collection to describe the index for.

  • index_name (String)

    The name of the index to describe.

Returns:

  • (Hash)

    Server response



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/milvus/indexes.rb', line 48

def describe(
  collection_name:,
  index_name:
)
  response = client.connection.post("#{PATH}/describe") do |req|
    req.body = {
      collectionName: collection_name,
      indexName: index_name
    }
  end
  response.body.empty? ? true : response.body
end

#drop(collection_name:, index_name:) ⇒ Hash

This operation deletes index from a specified collection.

Parameters:

  • collection_name (String)

    The name of the collection to delete the index from.

  • index_name (String)

    The name of the index to delete.

Returns:

  • (Hash)

    Server response



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/milvus/indexes.rb', line 30

def drop(
  collection_name:,
  index_name:
)
  response = client.connection.post("#{PATH}/drop") do |req|
    req.body = {
      collectionName: collection_name,
      indexName: index_name
    }
  end
  response.body.empty? ? true : response.body
end

#list(collection_name:) ⇒ Hash

This operation lists all indexes of a specific collection.

Parameters:

  • collection_name (String)

    The name of the collection to list indexes for.

Returns:

  • (Hash)

    Server response



65
66
67
68
69
70
71
72
73
74
# File 'lib/milvus/indexes.rb', line 65

def list(
  collection_name:
)
  response = client.connection.post("#{PATH}/list") do |req|
    req.body = {
      collectionName: collection_name
    }
  end
  response.body.empty? ? true : response.body
end