Class: Couchbase::Management::QueryIndexManager
- Inherits:
-
Object
- Object
- Couchbase::Management::QueryIndexManager
- Defined in:
- lib/couchbase/management/query_index_manager.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/management/query_index_manager.rb more...
Defined Under Namespace
Classes: BuildDeferredIndexOptions, CreateIndexOptions, CreatePrimaryIndexOptions, DropIndexOptions, DropPrimaryIndexOptions, GetAllIndexOptions, WatchIndexesOptions
Instance Method Summary collapse
-
#build_deferred_indexes(bucket_name, options = BuildDeferredIndexOptions.new) ⇒ Object
Build all indexes which are currently in deferred state.
-
#create_index(bucket_name, index_name, fields, options = CreateIndexOptions.new) ⇒ Object
Creates a new index.
-
#create_primary_index(bucket_name, options = CreatePrimaryIndexOptions.new) ⇒ Object
Creates new primary index.
-
#drop_index(bucket_name, index_name, options = DropIndexOptions.new) ⇒ Object
Drops the index.
-
#drop_primary_index(bucket_name, options = DropPrimaryIndexOptions.new) ⇒ Object
Drops the primary index.
-
#get_all_indexes(bucket_name, options = GetAllIndexOptions.new) ⇒ Array<QueryIndex>
Fetches all indexes from the server.
-
#initialize(backend) ⇒ QueryIndexManager
constructor
A new instance of QueryIndexManager.
-
#watch_indexes(bucket_name, index_names, timeout, options = WatchIndexesOptions.new) ⇒ Object
Polls indexes until they are online.
Constructor Details
#initialize(backend) ⇒ QueryIndexManager
Returns a new instance of QueryIndexManager.
23 24 25 |
# File 'lib/couchbase/management/query_index_manager.rb', line 23 def initialize(backend) @backend = backend end |
Instance Method Details
#build_deferred_indexes(bucket_name, options = BuildDeferredIndexOptions.new) ⇒ Object
Build all indexes which are currently in deferred state
141 142 143 |
# File 'lib/couchbase/management/query_index_manager.rb', line 141 def build_deferred_indexes(bucket_name, = BuildDeferredIndexOptions.new) @backend.query_index_build_deferred(bucket_name, .timeout) end |
#create_index(bucket_name, index_name, fields, options = CreateIndexOptions.new) ⇒ Object
Creates a new index
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/couchbase/management/query_index_manager.rb', line 65 def create_index(bucket_name, index_name, fields, = CreateIndexOptions.new) @backend.query_index_create(bucket_name, index_name, fields, { ignore_if_exists: .ignore_if_exists, condition: .condition, deferred: .deferred, num_replicas: .num_replicas, scope_name: .scope_name, collection_name: .collection_name, }, .timeout) end |
#create_primary_index(bucket_name, options = CreatePrimaryIndexOptions.new) ⇒ Object
Creates new primary index
85 86 87 88 89 90 91 92 93 |
# File 'lib/couchbase/management/query_index_manager.rb', line 85 def create_primary_index(bucket_name, = CreatePrimaryIndexOptions.new) @backend.query_index_create_primary(bucket_name, { ignore_if_exists: .ignore_if_exists, deferred: .deferred, num_replicas: .num_replicas, scope_name: .scope_name, collection_name: .collection_name, }, .timeout) end |
#drop_index(bucket_name, index_name, options = DropIndexOptions.new) ⇒ Object
Drops the index
105 106 107 108 109 110 111 112 |
# File 'lib/couchbase/management/query_index_manager.rb', line 105 def drop_index(bucket_name, index_name, = DropIndexOptions.new) @backend.query_index_drop(bucket_name, index_name, { ignore_if_does_not_exist: .ignore_if_does_not_exist, scope_name: .scope_name, collection_name: .collection_name, }, .timeout) true end |
#drop_primary_index(bucket_name, options = DropPrimaryIndexOptions.new) ⇒ Object
Drops the primary index
123 124 125 126 127 128 129 130 131 |
# File 'lib/couchbase/management/query_index_manager.rb', line 123 def drop_primary_index(bucket_name, = DropPrimaryIndexOptions.new) @backend.query_index_drop_primary(bucket_name, { ignore_if_does_not_exist: .ignore_if_does_not_exist, index_name: .index_name, scope_name: .scope_name, collection_name: .collection_name, }, .timeout) true end |
#get_all_indexes(bucket_name, options = GetAllIndexOptions.new) ⇒ Array<QueryIndex>
Fetches all indexes from the server
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/couchbase/management/query_index_manager.rb', line 35 def get_all_indexes(bucket_name, = GetAllIndexOptions.new) res = @backend.query_index_get_all(bucket_name, .timeout) res[:indexes].map do |idx| QueryIndex.new do |index| index.name = idx[:name] index.is_primary = idx[:is_primary] index.type = idx[:type] index.state = idx[:state] index.bucket = idx[:bucket_id] index.collection = idx[:collection_id] index.scope = idx[:scope_id] index.key_space = idx[:keyspace_id] index.name_space = idx[:namespace_id] index.index_key = idx[:index_key] index.condition = idx[:condition] end end end |
#watch_indexes(bucket_name, index_names, timeout, options = WatchIndexesOptions.new) ⇒ Object
Polls indexes until they are online
154 155 156 157 158 |
# File 'lib/couchbase/management/query_index_manager.rb', line 154 def watch_indexes(bucket_name, index_names, timeout, = WatchIndexesOptions.new) @backend.query_index_watch(bucket_name, index_names, timeout, { watch_primary: .watch_primary, }) end |