Class: Pinecone::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pinecone/client.rb

Instance Method Summary collapse

Instance Method Details

#configure_index(index_name, body) ⇒ Object



23
24
25
# File 'lib/pinecone/client.rb', line 23

def configure_index(index_name, body)
  Pinecone::Index.new.configure(index_name, body)
end

#create_collection(body) ⇒ Object



35
36
37
# File 'lib/pinecone/client.rb', line 35

def create_collection(body)
  Pinecone::Collection.new.create(body)
end

#create_index(body) ⇒ Object



15
16
17
# File 'lib/pinecone/client.rb', line 15

def create_index(body)
  Pinecone::Index.new.create(body)
end

#delete_collection(collection_name) ⇒ Object



39
40
41
# File 'lib/pinecone/client.rb', line 39

def delete_collection(collection_name)
  Pinecone::Collection.new.delete(collection_name)
end

#delete_index(index_name) ⇒ Object



19
20
21
# File 'lib/pinecone/client.rb', line 19

def delete_index(index_name)
  Pinecone::Index.new.delete(index_name)
end

#describe_collection(collection_name) ⇒ Object



31
32
33
# File 'lib/pinecone/client.rb', line 31

def describe_collection(collection_name)
  Pinecone::Collection.new.describe(collection_name)
end

#describe_index(index_name) ⇒ Object



11
12
13
# File 'lib/pinecone/client.rb', line 11

def describe_index(index_name)
  Pinecone::Index.new.describe(index_name)
end

#index(index_name = nil, host: nil) ⇒ Object

This is a very confusing naming convention Pinecone’s reference now delineates between ‘control plane’ and ‘data plane’ which we’ll reflect eventually

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pinecone/client.rb', line 45

def index(index_name = nil, host: nil)
  # Direct host provided
  return Pinecone::Vector.new(host: host) if host

  # Use global host if configured
  return Pinecone::Vector.new(host: Pinecone.configuration.host) if Pinecone.configuration.host

  # Legacy: index name provided
  if index_name
    unless Pinecone.configuration.silence_deprecation_warnings?
      warn "[DEPRECATED] client.index('name') is deprecated. Use client.index(host: 'host') for better performance."
    end
    return Pinecone::Vector.new(index_name)
  end

  # No host available
  raise ArgumentError,
    "No host provided. Set via Pinecone.configure { |c| c.host = 'host' } or client.index(host: 'host')"
end

#list_collectionsObject



27
28
29
# File 'lib/pinecone/client.rb', line 27

def list_collections
  Pinecone::Collection.new.list
end

#list_indexesObject



7
8
9
# File 'lib/pinecone/client.rb', line 7

def list_indexes
  Pinecone::Index.new.list
end