Class: Weaviate::Aliases

Inherits:
Base
  • Object
show all
Defined in:
lib/weaviate/aliases.rb,
sig/weaviate.rbs

Overview

Aliases are alternative names for a collection, e.g. to switch a "Products" alias to a newly built collection.

Constant Summary collapse

PATH =
"aliases"

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 Weaviate::Base

Instance Method Details

#create(alias_name:, class_name:) ⇒ json

Parameters:

  • alias_name: (String)
  • class_name: (String)

Returns:

  • (json)


15
16
17
18
19
20
# File 'lib/weaviate/aliases.rb', line 15

def create(alias_name:, class_name:)
  response = client.connection.post(PATH) do |req|
    req.body = {alias: alias_name, class: class_name}
  end
  response.body
end

#delete(alias_name:) ⇒ Boolean

Parameters:

  • alias_name: (String)

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/weaviate/aliases.rb', line 35

def delete(alias_name:)
  response = client.connection.delete("#{PATH}/#{alias_name}")
  response.success?
end

#get(alias_name:) ⇒ json

Parameters:

  • alias_name: (String)

Returns:

  • (json)


22
23
24
25
# File 'lib/weaviate/aliases.rb', line 22

def get(alias_name:)
  response = client.connection.get("#{PATH}/#{alias_name}")
  response.body
end

#list(class_name: nil) ⇒ json

Parameters:

  • class_name: (String, nil) (defaults to: nil)

Returns:

  • (json)


8
9
10
11
12
13
# File 'lib/weaviate/aliases.rb', line 8

def list(class_name: nil)
  response = client.connection.get(PATH) do |req|
    req.params["class"] = class_name unless class_name.nil?
  end
  response.body
end

#update(alias_name:, class_name:) ⇒ json

Point an alias to a different collection.

Parameters:

  • alias_name: (String)
  • class_name: (String)

Returns:

  • (json)


28
29
30
31
32
33
# File 'lib/weaviate/aliases.rb', line 28

def update(alias_name:, class_name:)
  response = client.connection.put("#{PATH}/#{alias_name}") do |req|
    req.body = {class: class_name}
  end
  response.body
end