Class: Couchbase::Management::SearchIndexManager
- Inherits:
-
Object
- Object
- Couchbase::Management::SearchIndexManager
- Defined in:
- lib/couchbase/management/search_index_manager.rb
Constant Summary collapse
- GetIndexOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::GetIndex instead
Options::Search::GetIndex
- GetAllIndexesOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::GetAllIndexes instead
Options::Search::GetAllIndexes
- UpsertIndexOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::UpsertIndex instead
Options::Search::UpsertIndex
- DropIndexOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::DropIndex instead
Options::Search::DropIndex
- GetIndexedDocumentsCountOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::GetIndexedDocumentsCount instead
Options::Search::GetIndexedDocumentsCount
- GetIndexStatsOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::GetIndexStats instead
Options::Search::GetIndexStats
- PauseIngestOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::PauseIngest instead
Options::Search::PauseIngest
- ResumeIngestOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::ResumeIngest instead
Options::Search::ResumeIngest
- AllowQueryingOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::AllowQuerying instead
Options::Search::AllowQuerying
- DisallowQueryingOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::DisallowQuerying instead
Options::Search::DisallowQuerying
- FreezePlanOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::FreezePlan instead
Options::Search::FreezePlan
- UnfreezePlanOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::UnfreezePlan instead
Options::Search::UnfreezePlan
- AnalyzeDocumentOptions =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Deprecated.use Options::Search::AnalyzeDocument instead
Options::Search::AnalyzeDocument
Class Method Summary collapse
Instance Method Summary collapse
-
#allow_querying(index_name, options = Options::Search::AllowQuerying::DEFAULT) ⇒ Object
Allows querying against the index.
-
#analyze_document(index_name, document, options = Options::Search::AnalyzeDocument::DEFAULT) ⇒ Array<Hash>
Allows to see how a document is analyzed against a specific index.
-
#disallow_querying(index_name, options = Options::Search::DisallowQuerying::DEFAULT) ⇒ Object
Disallows querying against the index.
-
#drop_index(index_name, options = Options::Search::DropIndex::DEFAULT) ⇒ Object
Drops the index.
-
#freeze_plan(index_name, options = Options::Search::FreezePlan::DEFAULT) ⇒ Object
Freeze the assignment of index partitions to nodes.
-
#get_all_indexes(options = Options::Search::GetAllIndexes::DEFAULT) ⇒ Array<SearchIndex>
Fetches all indexes from the server.
-
#get_index(index_name, options = Options::Search::GetIndex::DEFAULT) ⇒ SearchIndex
Fetches an index from the server if it exists.
-
#get_index_stats(index_name, options = Options::Search::GetIndexStats::DEFAULT) ⇒ Integer
Retrieves metrics, timings and counters for a given index.
-
#get_indexed_documents_count(index_name, options = Options::Search::GetIndexedDocumentsCount::DEFAULT) ⇒ Integer
Retrieves the number of documents that have been indexed for an index.
-
#get_stats(options = Options::Search::GetIndexStats::DEFAULT) ⇒ Integer
Retrieves statistics on search service.
-
#initialize(backend, observability) ⇒ SearchIndexManager
constructor
private
A new instance of SearchIndexManager.
-
#pause_ingest(index_name, options = Options::Search::PauseIngest::DEFAULT) ⇒ Object
Pauses updates and maintenance for the index.
-
#resume_ingest(index_name, options = Options::Search::ResumeIngest::DEFAULT) ⇒ Object
Resumes updates and maintenance for an index.
-
#unfreeze_plan(index_name, options = Options::Search::UnfreezePlan::DEFAULT) ⇒ Object
Unfreeze the assignment of index partitions to nodes.
-
#upsert_index(index_definition, options = Options::Search::UpsertIndex::DEFAULT) ⇒ Object
Creates or updates the index.
Constructor Details
#initialize(backend, observability) ⇒ SearchIndexManager
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SearchIndexManager.
293 294 295 296 |
# File 'lib/couchbase/management/search_index_manager.rb', line 293 def initialize(backend, observability) @backend = backend @observability = observability end |
Class Method Details
.extract_search_index(resp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/couchbase/management/search_index_manager.rb', line 583 def self.extract_search_index(resp) SearchIndex.new do |index| index.name = resp[:name] index.type = resp[:type] index.uuid = resp[:uuid] index.params = resp[:params] ? JSON.parse(resp[:params]) : {} index.source_name = resp[:source_name] index.source_type = resp[:source_type] index.source_uuid = resp[:source_uuid] index.source_params = resp[:source_params] ? JSON.parse(resp[:source_params]) : {} index.plan_params = resp[:plan_params] ? JSON.parse(resp[:plan_params]) : {} end end |
Instance Method Details
#allow_querying(index_name, options = Options::Search::AllowQuerying::DEFAULT) ⇒ Object
Allows querying against the index
462 463 464 465 466 |
# File 'lib/couchbase/management/search_index_manager.rb', line 462 def (index_name, = Options::Search::AllowQuerying::DEFAULT) @observability.record_operation(Observability::OP_SM_ALLOW_QUERYING, .parent_span, self, :search) do |obs_handler| @backend.(nil, nil, index_name, .timeout, obs_handler) end end |
#analyze_document(index_name, document, options = Options::Search::AnalyzeDocument::DEFAULT) ⇒ Array<Hash>
Allows to see how a document is analyzed against a specific index
523 524 525 526 527 528 |
# File 'lib/couchbase/management/search_index_manager.rb', line 523 def analyze_document(index_name, document, = Options::Search::AnalyzeDocument::DEFAULT) @observability.record_operation(Observability::OP_SM_ANALYZE_DOCUMENT, .parent_span, self, :search) do |obs_handler| res = @backend.search_index_analyze_document(nil, nil, index_name, JSON.generate(document), .timeout, obs_handler) JSON.parse(res[:analysis]) end end |
#disallow_querying(index_name, options = Options::Search::DisallowQuerying::DEFAULT) ⇒ Object
Disallows querying against the index
477 478 479 480 481 |
# File 'lib/couchbase/management/search_index_manager.rb', line 477 def (index_name, = Options::Search::DisallowQuerying::DEFAULT) @observability.record_operation(Observability::OP_SM_DISALLOW_QUERYING, .parent_span, self, :search) do |obs_handler| @backend.(nil, nil, index_name, .timeout, obs_handler) end end |
#drop_index(index_name, options = Options::Search::DropIndex::DEFAULT) ⇒ Object
Drops the index
365 366 367 368 369 |
# File 'lib/couchbase/management/search_index_manager.rb', line 365 def drop_index(index_name, = Options::Search::DropIndex::DEFAULT) @observability.record_operation(Observability::OP_SM_DROP_INDEX, .parent_span, self, :search) do |obs_handler| @backend.search_index_drop(nil, nil, index_name, .timeout, obs_handler) end end |
#freeze_plan(index_name, options = Options::Search::FreezePlan::DEFAULT) ⇒ Object
Freeze the assignment of index partitions to nodes
492 493 494 495 496 |
# File 'lib/couchbase/management/search_index_manager.rb', line 492 def freeze_plan(index_name, = Options::Search::FreezePlan::DEFAULT) @observability.record_operation(Observability::OP_SM_FREEZE_PLAN, .parent_span, self, :search) do |obs_handler| @backend.search_index_freeze_plan(nil, nil, index_name, .timeout, obs_handler) end end |
#get_all_indexes(options = Options::Search::GetAllIndexes::DEFAULT) ⇒ Array<SearchIndex>
Fetches all indexes from the server
319 320 321 322 323 324 |
# File 'lib/couchbase/management/search_index_manager.rb', line 319 def get_all_indexes( = Options::Search::GetAllIndexes::DEFAULT) @observability.record_operation(Observability::OP_SM_GET_ALL_INDEXES, .parent_span, self, :search) do |obs_handler| res = @backend.search_index_get_all(nil, nil, .timeout, obs_handler) res[:indexes].map { |idx| self.class.extract_search_index(idx) } end end |
#get_index(index_name, options = Options::Search::GetIndex::DEFAULT) ⇒ SearchIndex
Fetches an index from the server if it exists
307 308 309 310 311 312 |
# File 'lib/couchbase/management/search_index_manager.rb', line 307 def get_index(index_name, = Options::Search::GetIndex::DEFAULT) @observability.record_operation(Observability::OP_SM_GET_INDEX, .parent_span, self, :search) do |obs_handler| res = @backend.search_index_get(nil, nil, index_name, .timeout, obs_handler) self.class.extract_search_index(res) end end |
#get_index_stats(index_name, options = Options::Search::GetIndexStats::DEFAULT) ⇒ Integer
Retrieves metrics, timings and counters for a given index
399 400 401 402 403 404 |
# File 'lib/couchbase/management/search_index_manager.rb', line 399 def get_index_stats(index_name, = Options::Search::GetIndexStats::DEFAULT) @observability.record_operation(Observability::OP_SM_GET_INDEX_STATS, .parent_span, self, :search) do |obs_handler| res = @backend.search_index_get_stats(index_name, .timeout, obs_handler) JSON.parse(res) end end |
#get_indexed_documents_count(index_name, options = Options::Search::GetIndexedDocumentsCount::DEFAULT) ⇒ Integer
Retrieves the number of documents that have been indexed for an index
380 381 382 383 384 385 386 |
# File 'lib/couchbase/management/search_index_manager.rb', line 380 def get_indexed_documents_count(index_name, = Options::Search::GetIndexedDocumentsCount::DEFAULT) @observability.record_operation(Observability::OP_SM_GET_INDEXED_DOCUMENTS_COUNT, .parent_span, self, :search) do |obs_handler| res = @backend.search_index_get_documents_count(nil, nil, index_name, .timeout, obs_handler) res[:count] end end |
#get_stats(options = Options::Search::GetIndexStats::DEFAULT) ⇒ Integer
Retrieves statistics on search service. Information is provided on documents, partition indexes, mutations, compactions, queries, and more.
416 417 418 419 420 421 |
# File 'lib/couchbase/management/search_index_manager.rb', line 416 def get_stats( = Options::Search::GetIndexStats::DEFAULT) @observability.record_operation(Observability::OP_SM_GET_STATS, .parent_span, self, :search) do |obs_handler| res = @backend.search_get_stats(.timeout, obs_handler) JSON.parse(res) end end |
#pause_ingest(index_name, options = Options::Search::PauseIngest::DEFAULT) ⇒ Object
Pauses updates and maintenance for the index
432 433 434 435 436 |
# File 'lib/couchbase/management/search_index_manager.rb', line 432 def pause_ingest(index_name, = Options::Search::PauseIngest::DEFAULT) @observability.record_operation(Observability::OP_SM_PAUSE_INGEST, .parent_span, self, :search) do |obs_handler| @backend.search_index_pause_ingest(nil, nil, index_name, .timeout, obs_handler) end end |
#resume_ingest(index_name, options = Options::Search::ResumeIngest::DEFAULT) ⇒ Object
Resumes updates and maintenance for an index
447 448 449 450 451 |
# File 'lib/couchbase/management/search_index_manager.rb', line 447 def resume_ingest(index_name, = Options::Search::ResumeIngest::DEFAULT) @observability.record_operation(Observability::OP_SM_RESUME_INGEST, .parent_span, self, :search) do |obs_handler| @backend.search_index_resume_ingest(nil, nil, index_name, .timeout, obs_handler) end end |
#unfreeze_plan(index_name, options = Options::Search::UnfreezePlan::DEFAULT) ⇒ Object
Unfreeze the assignment of index partitions to nodes
507 508 509 510 511 |
# File 'lib/couchbase/management/search_index_manager.rb', line 507 def unfreeze_plan(index_name, = Options::Search::UnfreezePlan::DEFAULT) @observability.record_operation(Observability::OP_SM_UNFREEZE_PLAN, .parent_span, self, :search) do |obs_handler| @backend.search_index_unfreeze_plan(nil, nil, index_name, .timeout, obs_handler) end end |
#upsert_index(index_definition, options = Options::Search::UpsertIndex::DEFAULT) ⇒ Object
Creates or updates the index
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/couchbase/management/search_index_manager.rb', line 334 def upsert_index(index_definition, = Options::Search::UpsertIndex::DEFAULT) @observability.record_operation(Observability::OP_SM_UPSERT_INDEX, .parent_span, self, :search) do |obs_handler| @backend.search_index_upsert( nil, nil, { name: index_definition.name, type: index_definition.type, uuid: index_definition.uuid, params: (JSON.generate(index_definition.params) if index_definition.params), source_name: index_definition.source_name, source_type: index_definition.source_type, source_uuid: index_definition.source_uuid, source_params: (JSON.generate(index_definition.source_params) if index_definition.source_params), plan_params: (JSON.generate(index_definition.plan_params) if index_definition.plan_params), }, .timeout, obs_handler, ) end end |