Class: Couchbase::Management::ScopeSearchIndexManager

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/management/scope_search_index_manager.rb

Constant Summary collapse

GetIndexOptions =
SearchIndexManager::GetIndexOptions
GetAllIndexesOptions =
SearchIndexManager::GetAllIndexesOptions
UpsertIndexOptions =
SearchIndexManager::UpsertIndexOptions
DropIndexOptions =
SearchIndexManager::DropIndexOptions
GetIndexedDocumentsCountOptions =
SearchIndexManager::GetIndexedDocumentsCountOptions
PauseIngestOptions =
SearchIndexManager::PauseIngestOptions
ResumeIngestOptions =
SearchIndexManager::ResumeIngestOptions
AllowQueryingOptions =
SearchIndexManager::AllowQueryingOptions
DisallowQueryingOptions =
SearchIndexManager::DisallowQueryingOptions
FreezePlanOptions =
SearchIndexManager::FreezePlanOptions
UnfreezePlanOptions =
SearchIndexManager::UnfreezePlanOptions
AnalyzeDocumentOptions =
SearchIndexManager::AnalyzeDocumentOptions

Instance Method Summary collapse

Constructor Details

#initialize(backend, bucket_name, scope_name) ⇒ ScopeSearchIndexManager

Returns a new instance of ScopeSearchIndexManager.

Parameters:

  • backend (Couchbase::Backend)
  • bucket_name (String)
  • scope_name (String)


23
24
25
26
27
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 23

def initialize(backend, bucket_name, scope_name)
  @backend = backend
  @bucket_name = bucket_name
  @scope_name = scope_name
end

Instance Method Details

#allow_querying(index_name, options = AllowQueryingOptions.new) ⇒ Object

Allows querying against the index

Parameters:

  • index_name (String)

    name of the index

  • options (AllowQueryingOptions) (defaults to: AllowQueryingOptions.new)

Returns:

  • void

Raises:



127
128
129
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 127

def allow_querying(index_name, options = AllowQueryingOptions.new)
  @backend.search_index_allow_querying(@bucket_name, @scope_name, index_name, options.timeout)
end

#analyze_document(index_name, document, options = AnalyzeDocumentOptions.new) ⇒ Array<Hash>

Allows to see how a document is analyzed against a specific index

Parameters:

  • index_name (String)

    name of the index

  • document (Hash)

    the document to be analyzed

Returns:

  • (Array<Hash>)

Raises:



179
180
181
182
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 179

def analyze_document(index_name, document, options = AnalyzeDocumentOptions.new)
  res = @backend.search_index_analyze_document(@bucket_name, @scope_name, index_name, JSON.generate(document), options.timeout)
  JSON.parse(res[:analysis])
end

#disallow_querying(index_name, options = DisallowQueryingOptions.new) ⇒ Object

Disallows querying against the index

Parameters:

  • index_name (String)

    name of the index

  • options (DisallowQueryingOptions) (defaults to: DisallowQueryingOptions.new)

Returns:

  • void

Raises:



140
141
142
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 140

def disallow_querying(index_name, options = DisallowQueryingOptions.new)
  @backend.search_index_disallow_querying(@bucket_name, @scope_name, index_name, options.timeout)
end

#drop_index(index_name, options = DropIndexOptions.new) ⇒ Object

Drops the index

Parameters:

  • index_name (String)

    name of the index

  • options (DropIndexOptions) (defaults to: DropIndexOptions.new)

Returns:

  • void

Raises:



74
75
76
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 74

def drop_index(index_name, options = DropIndexOptions.new)
  @backend.search_index_drop(@bucket_name, @scope_name, index_name, options.timeout)
end

#freeze_plan(index_name, options = FreezePlanOptions.new) ⇒ Object

Freeze the assignment of index partitions to nodes

Parameters:

  • index_name (String)

    name of the index

  • options (FreezePlanOptions) (defaults to: FreezePlanOptions.new)

Returns:

  • void

Raises:



153
154
155
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 153

def freeze_plan(index_name, options = FreezePlanOptions.new)
  @backend.search_index_freeze_plan(@bucket_name, @scope_name, index_name, options.timeout)
end

#get_all_indexes(options = GetAllIndexesOptions.new) ⇒ Array<SearchIndex>

Fetches all indexes from the server

Parameters:

Returns:



48
49
50
51
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 48

def get_all_indexes(options = GetAllIndexesOptions.new)
  res = @backend.search_index_get_all(@bucket_name, @scope_name, options.timeout)
  res[:indexes].map { |idx| SearchIndexManager.extract_search_index(idx) }
end

#get_index(index_name, options = GetIndexOptions.new) ⇒ SearchIndex

Fetches an index from the server if it exists

Parameters:

  • index_name (String)

    name of the index

  • options (GetIndexOptions) (defaults to: GetIndexOptions.new)

Returns:

Raises:



38
39
40
41
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 38

def get_index(index_name, options = GetIndexOptions.new)
  res = @backend.search_index_get(@bucket_name, @scope_name, index_name, options.timeout)
  SearchIndexManager.extract_search_index(res)
end

#get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new) ⇒ Integer

Retrieves the number of documents that have been indexed for an index

Parameters:

Returns:

  • (Integer)

Raises:



87
88
89
90
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 87

def get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new)
  res = @backend.search_index_get_documents_count(@bucket_name, @scope_name, index_name, options.timeout)
  res[:count]
end

#pause_ingest(index_name, options = PauseIngestOptions.new) ⇒ Object

Pauses updates and maintenance for the index

Parameters:

  • index_name (String)

    name of the index

  • options (PauseIngestOptions) (defaults to: PauseIngestOptions.new)

Returns:

  • void

Raises:



101
102
103
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 101

def pause_ingest(index_name, options = PauseIngestOptions.new)
  @backend.search_index_pause_ingest(@bucket_name, @scope_name, index_name, options.timeout)
end

#resume_ingest(index_name, options = ResumeIngestOptions.new) ⇒ Object

Resumes updates and maintenance for an index

Parameters:

  • index_name (String)

    name of the index

  • options (ResumeIngestOptions) (defaults to: ResumeIngestOptions.new)

Returns:

  • void

Raises:



114
115
116
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 114

def resume_ingest(index_name, options = ResumeIngestOptions.new)
  @backend.search_index_resume_ingest(@bucket_name, @scope_name, index_name, options.timeout)
end

#unfreeze_plan(index_name, options = UnfreezePlanOptions.new) ⇒ Object

Unfreeze the assignment of index partitions to nodes

Parameters:

  • index_name (String)

    name of the index

  • options (UnfreezePlanOptions) (defaults to: UnfreezePlanOptions.new)

Returns:

  • void

Raises:



166
167
168
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 166

def unfreeze_plan(index_name, options = UnfreezePlanOptions.new)
  @backend.search_index_unfreeze_plan(@bucket_name, @scope_name, index_name, options.timeout)
end

#upsert_index(index_definition, options = UpsertIndexOptions.new) ⇒ Object

Creates or updates the index

Parameters:

Returns:

  • void

Raises:

  • (ArgumentError)

    if name, type or source_type is empty



61
62
63
# File 'lib/couchbase/management/scope_search_index_manager.rb', line 61

def upsert_index(index_definition, options = UpsertIndexOptions.new)
  @backend.search_index_upsert(@bucket_name, @scope_name, index_definition.to_backend, options.timeout)
end