Class: Couchbase::Management::SearchIndexManager
- Inherits:
-
Object
- Object
- Couchbase::Management::SearchIndexManager
- Defined in:
- lib/couchbase/management/search_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/management/search_index_manager.rb
Defined Under Namespace
Classes: AllowQueryingOptions, AnalyzeDocumentOptions, DisallowQueryingOptions, DropIndexOptions, FreezePlanOptions, GetAllIndexesOptions, GetIndexOptions, GetIndexStatsOptions, GetIndexedDocumentsCountOptions, PauseIngestOptions, ResumeIngestOptions, UnfreezePlanOptions, UpsertIndexOptions
Instance Method Summary collapse
-
#allow_querying(index_name, options = AllowQueryingOptions.new) ⇒ Object
Allows querying against the index.
-
#analyze_document(index_name, document, options = AnalyzeDocumentOptions.new) ⇒ Array<Hash>
Allows to see how a document is analyzed against a specific index.
-
#disallow_querying(index_name, options = DisallowQueryingOptions.new) ⇒ Object
Disallows querying against the index.
-
#drop_index(index_name, options = DropIndexOptions.new) ⇒ Object
Drops the index.
-
#freeze_plan(index_name, options = FreezePlanOptions.new) ⇒ Object
Freeze the assignment of index partitions to nodes.
-
#get_all_indexes(options = GetAllIndexesOptions.new) ⇒ Array<SearchIndex>
Fetches all indexes from the server.
-
#get_index(index_name, options = GetIndexOptions.new) ⇒ SearchIndex
Fetches an index from the server if it exists.
-
#get_index_stats(index_name, options = GetIndexStatsOptions.new) ⇒ Integer
Retrieves metrics, timings and counters for a given index.
-
#get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new) ⇒ Integer
Retrieves the number of documents that have been indexed for an index.
-
#get_stats(options = GetIndexStatsOptions.new) ⇒ Integer
Retrieves statistics on search service.
-
#initialize(backend) ⇒ SearchIndexManager
constructor
A new instance of SearchIndexManager.
-
#pause_ingest(index_name, options = PauseIngestOptions.new) ⇒ Object
Pauses updates and maintenance for the index.
-
#resume_ingest(index_name, options = ResumeIngestOptions.new) ⇒ Object
Resumes updates and maintenance for an index.
-
#unfreeze_plan(index_name, options = UnfreezePlanOptions.new) ⇒ Object
Unfreeze the assignment of index partitions to nodes.
-
#upsert_index(index_definition, options = UpsertIndexOptions.new) ⇒ Object
Creates or updates the index.
Constructor Details
#initialize(backend) ⇒ SearchIndexManager
Returns a new instance of SearchIndexManager.
25 26 27 |
# File 'lib/couchbase/management/search_index_manager.rb', line 25 def initialize(backend) @backend = backend end |
Instance Method Details
#allow_querying(index_name, options = AllowQueryingOptions.new) ⇒ Object
Allows querying against the index
172 173 174 |
# File 'lib/couchbase/management/search_index_manager.rb', line 172 def (index_name, = AllowQueryingOptions.new) @backend.(nil, nil, index_name, .timeout) end |
#analyze_document(index_name, document, options = AnalyzeDocumentOptions.new) ⇒ Array<Hash>
Allows to see how a document is analyzed against a specific index
224 225 226 227 |
# File 'lib/couchbase/management/search_index_manager.rb', line 224 def analyze_document(index_name, document, = AnalyzeDocumentOptions.new) res = @backend.search_index_analyze_document(nil, nil, index_name, JSON.generate(document), .timeout) JSON.parse(res[:analysis]) end |
#disallow_querying(index_name, options = DisallowQueryingOptions.new) ⇒ Object
Disallows querying against the index
185 186 187 |
# File 'lib/couchbase/management/search_index_manager.rb', line 185 def (index_name, = DisallowQueryingOptions.new) @backend.(nil, nil, index_name, .timeout) end |
#drop_index(index_name, options = DropIndexOptions.new) ⇒ Object
Drops the index
88 89 90 |
# File 'lib/couchbase/management/search_index_manager.rb', line 88 def drop_index(index_name, = DropIndexOptions.new) @backend.search_index_drop(nil, nil, index_name, .timeout) end |
#freeze_plan(index_name, options = FreezePlanOptions.new) ⇒ Object
Freeze the assignment of index partitions to nodes
198 199 200 |
# File 'lib/couchbase/management/search_index_manager.rb', line 198 def freeze_plan(index_name, = FreezePlanOptions.new) @backend.search_index_freeze_plan(nil, nil, index_name, .timeout) end |
#get_all_indexes(options = GetAllIndexesOptions.new) ⇒ Array<SearchIndex>
Fetches all indexes from the server
48 49 50 51 |
# File 'lib/couchbase/management/search_index_manager.rb', line 48 def get_all_indexes( = GetAllIndexesOptions.new) res = @backend.search_index_get_all(nil, nil, .timeout) res[:indexes].map { |idx| self.class.extract_search_index(idx) } end |
#get_index(index_name, options = GetIndexOptions.new) ⇒ SearchIndex
Fetches an index from the server if it exists
38 39 40 41 |
# File 'lib/couchbase/management/search_index_manager.rb', line 38 def get_index(index_name, = GetIndexOptions.new) res = @backend.search_index_get(nil, nil, index_name, .timeout) self.class.extract_search_index(res) end |
#get_index_stats(index_name, options = GetIndexStatsOptions.new) ⇒ Integer
Retrieves metrics, timings and counters for a given index
117 118 119 120 |
# File 'lib/couchbase/management/search_index_manager.rb', line 117 def get_index_stats(index_name, = GetIndexStatsOptions.new) res = @backend.search_index_get_stats(index_name, .timeout) JSON.parse(res) end |
#get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new) ⇒ Integer
Retrieves the number of documents that have been indexed for an index
101 102 103 104 |
# File 'lib/couchbase/management/search_index_manager.rb', line 101 def get_indexed_documents_count(index_name, = GetIndexedDocumentsCountOptions.new) res = @backend.search_index_get_documents_count(nil, nil, index_name, .timeout) res[:count] end |
#get_stats(options = GetIndexStatsOptions.new) ⇒ Integer
Retrieves statistics on search service. Information is provided on documents, partition indexes, mutations, compactions, queries, and more.
132 133 134 135 |
# File 'lib/couchbase/management/search_index_manager.rb', line 132 def get_stats( = GetIndexStatsOptions.new) res = @backend.search_get_stats(.timeout) JSON.parse(res) end |
#pause_ingest(index_name, options = PauseIngestOptions.new) ⇒ Object
Pauses updates and maintenance for the index
146 147 148 |
# File 'lib/couchbase/management/search_index_manager.rb', line 146 def pause_ingest(index_name, = PauseIngestOptions.new) @backend.search_index_pause_ingest(nil, nil, index_name, .timeout) end |
#resume_ingest(index_name, options = ResumeIngestOptions.new) ⇒ Object
Resumes updates and maintenance for an index
159 160 161 |
# File 'lib/couchbase/management/search_index_manager.rb', line 159 def resume_ingest(index_name, = ResumeIngestOptions.new) @backend.search_index_resume_ingest(nil, nil, index_name, .timeout) end |
#unfreeze_plan(index_name, options = UnfreezePlanOptions.new) ⇒ Object
Unfreeze the assignment of index partitions to nodes
211 212 213 |
# File 'lib/couchbase/management/search_index_manager.rb', line 211 def unfreeze_plan(index_name, = UnfreezePlanOptions.new) @backend.search_index_unfreeze_plan(nil, nil, index_name, .timeout) end |
#upsert_index(index_definition, options = UpsertIndexOptions.new) ⇒ Object
Creates or updates the index
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/couchbase/management/search_index_manager.rb', line 61 def upsert_index(index_definition, = UpsertIndexOptions.new) @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 ) end |