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...
Instance Method Summary collapse
-
#build_deferred_indexes(bucket_name, options = Options::Query::BuildDeferredIndexes.new) ⇒ Object
Build all indexes which are currently in deferred state.
-
#create_index(bucket_name, index_name, fields, options = Options::Query::CreateIndex.new) ⇒ Object
Creates a new index.
-
#create_primary_index(bucket_name, options = Options::Query::CreatePrimaryIndex.new) ⇒ Object
Creates new primary index.
-
#drop_index(bucket_name, index_name, options = Options::Query::DropIndex.new) ⇒ Object
Drops the index.
-
#drop_primary_index(bucket_name, options = Options::Query::DropPrimaryIndex.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 = Options::Query::WatchIndexes.new) ⇒ Object
Polls indexes until they are online.
Constructor Details
#initialize(backend) ⇒ QueryIndexManager
Returns a new instance of QueryIndexManager.
332 333 334 |
# File 'lib/couchbase/management/query_index_manager.rb', line 332 def initialize(backend) @backend = backend end |
Instance Method Details
#build_deferred_indexes(bucket_name, options = Options::Query::BuildDeferredIndexes.new) ⇒ Object
Build all indexes which are currently in deferred state
429 430 431 |
# File 'lib/couchbase/management/query_index_manager.rb', line 429 def build_deferred_indexes(bucket_name, = Options::Query::BuildDeferredIndexes.new) @backend.query_index_build_deferred(bucket_name, .to_backend) end |
#create_index(bucket_name, index_name, fields, options = Options::Query::CreateIndex.new) ⇒ Object
Creates a new index
375 376 377 |
# File 'lib/couchbase/management/query_index_manager.rb', line 375 def create_index(bucket_name, index_name, fields, = Options::Query::CreateIndex.new) @backend.query_index_create(bucket_name, index_name, fields, .to_backend) end |
#create_primary_index(bucket_name, options = Options::Query::CreatePrimaryIndex.new) ⇒ Object
Creates new primary index
388 389 390 |
# File 'lib/couchbase/management/query_index_manager.rb', line 388 def create_primary_index(bucket_name, = Options::Query::CreatePrimaryIndex.new) @backend.query_index_create_primary(bucket_name, .to_backend) end |
#drop_index(bucket_name, index_name, options = Options::Query::DropIndex.new) ⇒ Object
Drops the index
402 403 404 405 |
# File 'lib/couchbase/management/query_index_manager.rb', line 402 def drop_index(bucket_name, index_name, = Options::Query::DropIndex.new) @backend.query_index_drop(bucket_name, index_name, .to_backend) true end |
#drop_primary_index(bucket_name, options = Options::Query::DropPrimaryIndex.new) ⇒ Object
Drops the primary index
416 417 418 419 |
# File 'lib/couchbase/management/query_index_manager.rb', line 416 def drop_primary_index(bucket_name, = Options::Query::DropPrimaryIndex.new) @backend.query_index_drop_primary(bucket_name, .to_backend) true end |
#get_all_indexes(bucket_name, options = GetAllIndexOptions.new) ⇒ Array<QueryIndex>
Fetches all indexes from the server
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/couchbase/management/query_index_manager.rb', line 344 def get_all_indexes(bucket_name, = GetAllIndexOptions.new) res = @backend.query_index_get_all(bucket_name, .to_backend) 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] index.partition = idx[:partition] end end end |
#watch_indexes(bucket_name, index_names, timeout, options = Options::Query::WatchIndexes.new) ⇒ Object
Polls indexes until they are online
442 443 444 445 446 |
# File 'lib/couchbase/management/query_index_manager.rb', line 442 def watch_indexes(bucket_name, index_names, timeout, = Options::Query::WatchIndexes.new) @backend.query_index_watch(bucket_name, index_names, timeout.respond_to?(:in_milliseconds) ? timeout.public_send(:in_milliseconds) : timeout, .to_backend) end |