1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17+ require_relative "search_index_manager"
18+
1719module Couchbase
1820 module Management
1921 class ScopeSearchIndexManager
@@ -31,170 +33,206 @@ def initialize(backend, bucket_name, scope_name)
3133 # Fetches an index from the server if it exists
3234 #
3335 # @param [String] index_name name of the index
34- # @param [GetIndexOptions ] options
36+ # @param [Options::Search::GetIndex ] options
3537 #
3638 # @return [SearchIndex]
3739 #
3840 # @raise [ArgumentError]
3941 # @raise [Error::IndexNotFound]
40- def get_index ( index_name , options = GetIndexOptions . new )
42+ def get_index ( index_name , options = Options :: Search :: GetIndex :: DEFAULT )
4143 res = @backend . search_index_get ( @bucket_name , @scope_name , index_name , options . timeout )
4244 SearchIndexManager . extract_search_index ( res )
4345 end
4446
4547 # Fetches all indexes from the server
4648 #
47- # @param [GetAllIndexesOptions ] options
49+ # @param [Options::Search::GetAllIndexes ] options
4850 #
4951 # @return [Array<SearchIndex>]
50- def get_all_indexes ( options = GetAllIndexesOptions . new )
52+ def get_all_indexes ( options = Options :: Search :: GetAllIndexes :: DEFAULT )
5153 res = @backend . search_index_get_all ( @bucket_name , @scope_name , options . timeout )
5254 res [ :indexes ] . map { |idx | SearchIndexManager . extract_search_index ( idx ) }
5355 end
5456
5557 # Creates or updates the index
5658 #
5759 # @param [SearchIndex] index_definition the index definition
58- # @param [UpsertIndexOptions ] options
60+ # @param [Options::Search::UpsertIndex ] options
5961 #
6062 # @return void
6163 #
6264 # @raise [ArgumentError] if name, type or source_type is empty
63- def upsert_index ( index_definition , options = UpsertIndexOptions . new )
65+ def upsert_index ( index_definition , options = Options :: Search :: UpsertIndex :: DEFAULT )
6466 @backend . search_index_upsert ( @bucket_name , @scope_name , index_definition . to_backend , options . timeout )
6567 end
6668
6769 # Drops the index
6870 #
6971 # @param [String] index_name name of the index
70- # @param [DropIndexOptions ] options
72+ # @param [Options::Search::DropIndex ] options
7173 #
7274 # @return void
7375 #
7476 # @raise [ArgumentError]
7577 # @raise [Error::IndexNotFound]
76- def drop_index ( index_name , options = DropIndexOptions . new )
78+ def drop_index ( index_name , options = Options :: Search :: DropIndex :: DEFAULT )
7779 @backend . search_index_drop ( @bucket_name , @scope_name , index_name , options . timeout )
7880 end
7981
8082 # Retrieves the number of documents that have been indexed for an index
8183 #
8284 # @param [String] index_name name of the index
83- # @param [GetIndexedDocumentsCountOptions ] options
85+ # @param [Options::Search::GetIndexedDocumentsCount ] options
8486 #
8587 # @return [Integer]
8688 #
8789 # @raise [ArgumentError]
8890 # @raise [Error::IndexNotFound]
89- def get_indexed_documents_count ( index_name , options = GetIndexedDocumentsCountOptions . new )
91+ def get_indexed_documents_count ( index_name , options = Options :: Search :: GetIndexedDocumentsCount :: DEFAULT )
9092 res = @backend . search_index_get_documents_count ( @bucket_name , @scope_name , index_name , options . timeout )
9193 res [ :count ]
9294 end
9395
9496 # Pauses updates and maintenance for the index
9597 #
9698 # @param [String] index_name name of the index
97- # @param [PauseIngestOptions ] options
99+ # @param [Options::Search::PauseIngest ] options
98100 #
99101 # @return void
100102 #
101103 # @raise [ArgumentError]
102104 # @raise [Error::IndexNotFound]
103- def pause_ingest ( index_name , options = PauseIngestOptions . new )
105+ def pause_ingest ( index_name , options = Options :: Search :: PauseIngest :: DEFAULT )
104106 @backend . search_index_pause_ingest ( @bucket_name , @scope_name , index_name , options . timeout )
105107 end
106108
107109 # Resumes updates and maintenance for an index
108110 #
109111 # @param [String] index_name name of the index
110- # @param [ResumeIngestOptions ] options
112+ # @param [Options::Search::ResumeIngest ] options
111113 #
112114 # @return void
113115 #
114116 # @raise [ArgumentError]
115117 # @raise [Error::IndexNotFound]
116- def resume_ingest ( index_name , options = ResumeIngestOptions . new )
118+ def resume_ingest ( index_name , options = Options :: Search :: ResumeIngest :: DEFAULT )
117119 @backend . search_index_resume_ingest ( @bucket_name , @scope_name , index_name , options . timeout )
118120 end
119121
120122 # Allows querying against the index
121123 #
122124 # @param [String] index_name name of the index
123- # @param [AllowQueryingOptions ] options
125+ # @param [Options::Search::AllowQuerying ] options
124126 #
125127 # @return void
126128 #
127129 # @raise [ArgumentError]
128130 # @raise [Error::IndexNotFound]
129- def allow_querying ( index_name , options = AllowQueryingOptions . new )
131+ def allow_querying ( index_name , options = Options :: Search :: AllowQuerying :: DEFAULT )
130132 @backend . search_index_allow_querying ( @bucket_name , @scope_name , index_name , options . timeout )
131133 end
132134
133135 # Disallows querying against the index
134136 #
135137 # @param [String] index_name name of the index
136- # @param [DisallowQueryingOptions ] options
138+ # @param [Options::Search::DisallowQuerying ] options
137139 #
138140 # @return void
139141 #
140142 # @raise [ArgumentError]
141143 # @raise [Error::IndexNotFound]
142- def disallow_querying ( index_name , options = DisallowQueryingOptions . new )
144+ def disallow_querying ( index_name , options = Options :: Search :: DisallowQuerying :: DEFAULT )
143145 @backend . search_index_disallow_querying ( @bucket_name , @scope_name , index_name , options . timeout )
144146 end
145147
146148 # Freeze the assignment of index partitions to nodes
147149 #
148150 # @param [String] index_name name of the index
149- # @param [FreezePlanOptions ] options
151+ # @param [Options::Search::FreezePlan ] options
150152 #
151153 # @return void
152154 #
153155 # @raise [ArgumentError]
154156 # @raise [Error::IndexNotFound]
155- def freeze_plan ( index_name , options = FreezePlanOptions . new )
157+ def freeze_plan ( index_name , options = Options :: Search :: FreezePlan :: DEFAULT )
156158 @backend . search_index_freeze_plan ( @bucket_name , @scope_name , index_name , options . timeout )
157159 end
158160
159161 # Unfreeze the assignment of index partitions to nodes
160162 #
161163 # @param [String] index_name name of the index
162- # @param [UnfreezePlanOptions ] options
164+ # @param [Options::Search::UnfreezePlan ] options
163165 #
164166 # @return void
165167 #
166168 # @raise [ArgumentError]
167169 # @raise [Error::IndexNotFound]
168- def unfreeze_plan ( index_name , options = UnfreezePlanOptions . new )
170+ def unfreeze_plan ( index_name , options = Options :: Search :: UnfreezePlan :: DEFAULT )
169171 @backend . search_index_unfreeze_plan ( @bucket_name , @scope_name , index_name , options . timeout )
170172 end
171173
172174 # Allows to see how a document is analyzed against a specific index
173175 #
174176 # @param [String] index_name name of the index
175177 # @param [Hash] document the document to be analyzed
178+ # @param [Options::Search::AnalyzeDocument] options
176179 #
177180 # @return [Array<Hash>]
178181 #
179182 # @raise [ArgumentError]
180183 # @raise [Error::IndexNotFound]
181- def analyze_document ( index_name , document , options = AnalyzeDocumentOptions . new )
184+ def analyze_document ( index_name , document , options = Options :: Search :: AnalyzeDocument :: DEFAULT )
182185 res = @backend . search_index_analyze_document ( @bucket_name , @scope_name , index_name , JSON . generate ( document ) , options . timeout )
183186 JSON . parse ( res [ :analysis ] )
184187 end
185188
186- GetIndexOptions = SearchIndexManager ::GetIndexOptions
187- GetAllIndexesOptions = SearchIndexManager ::GetAllIndexesOptions
188- UpsertIndexOptions = SearchIndexManager ::UpsertIndexOptions
189- DropIndexOptions = SearchIndexManager ::DropIndexOptions
190- GetIndexedDocumentsCountOptions = SearchIndexManager ::GetIndexedDocumentsCountOptions
191- PauseIngestOptions = SearchIndexManager ::PauseIngestOptions
192- ResumeIngestOptions = SearchIndexManager ::ResumeIngestOptions
193- AllowQueryingOptions = SearchIndexManager ::AllowQueryingOptions
194- DisallowQueryingOptions = SearchIndexManager ::DisallowQueryingOptions
195- FreezePlanOptions = SearchIndexManager ::FreezePlanOptions
196- UnfreezePlanOptions = SearchIndexManager ::UnfreezePlanOptions
197- AnalyzeDocumentOptions = SearchIndexManager ::AnalyzeDocumentOptions
189+ # @api private
190+ # @deprecated use {Options::Search::GetIndex} instead
191+ GetIndexOptions = Options ::Search ::GetIndex
192+
193+ # @api private
194+ # @deprecated use {Options::Search::GetAllIndexes} instead
195+ GetAllIndexesOptions = Options ::Search ::GetAllIndexes
196+
197+ # @api private
198+ # @deprecated use {Options::Search::UpsertIndex} instead
199+ UpsertIndexOptions = Options ::Search ::UpsertIndex
200+
201+ # @api private
202+ # @deprecated use {Options::Search::DropIndex} instead
203+ DropIndexOptions = Options ::Search ::DropIndex
204+
205+ # @api private
206+ # @deprecated use {Options::Search::GetIndexedDocumentsCount} instead
207+ GetIndexedDocumentsCountOptions = Options ::Search ::GetIndexedDocumentsCount
208+
209+ # @api private
210+ # @deprecated use {Options::Search::PauseIngest} instead
211+ PauseIngestOptions = Options ::Search ::PauseIngest
212+
213+ # @api private
214+ # @deprecated use {Options::Search::ResumeIngest} instead
215+ ResumeIngestOptions = Options ::Search ::ResumeIngest
216+
217+ # @api private
218+ # @deprecated use {Options::Search::AllowQuerying} instead
219+ AllowQueryingOptions = Options ::Search ::AllowQuerying
220+
221+ # @api private
222+ # @deprecated use {Options::Search::DisallowQuerying} instead
223+ DisallowQueryingOptions = Options ::Search ::DisallowQuerying
224+
225+ # @api private
226+ # @deprecated use {Options::Search::FreezePlan} instead
227+ FreezePlanOptions = Options ::Search ::FreezePlan
228+
229+ # @api private
230+ # @deprecated use {Options::Search::UnfreezePlan} instead
231+ UnfreezePlanOptions = Options ::Search ::UnfreezePlan
232+
233+ # @api private
234+ # @deprecated use {Options::Search::AnalyzeDocument} instead
235+ AnalyzeDocumentOptions = Options ::Search ::AnalyzeDocument
198236 end
199237 end
200238end
0 commit comments