couchbase 3.0.0.alpha.2 → 3.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests-dev-preview.yml +52 -0
- data/.gitmodules +3 -0
- data/.idea/vcs.xml +1 -0
- data/.yardopts +1 -0
- data/README.md +1 -1
- data/Rakefile +5 -1
- data/bin/init-cluster +13 -5
- data/couchbase.gemspec +2 -1
- data/examples/managing_query_indexes.rb +1 -1
- data/examples/managing_search_indexes.rb +62 -0
- data/examples/search.rb +187 -0
- data/ext/.clang-tidy +1 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/couchbase/bucket.hxx +0 -40
- data/ext/couchbase/couchbase.cxx +2578 -1368
- data/ext/couchbase/io/http_session.hxx +27 -7
- data/ext/couchbase/io/mcbp_parser.hxx +2 -0
- data/ext/couchbase/io/mcbp_session.hxx +53 -24
- data/ext/couchbase/io/session_manager.hxx +6 -1
- data/ext/couchbase/operations.hxx +13 -0
- data/ext/couchbase/operations/bucket_create.hxx +1 -0
- data/ext/couchbase/operations/bucket_drop.hxx +1 -0
- data/ext/couchbase/operations/bucket_flush.hxx +1 -0
- data/ext/couchbase/operations/bucket_get.hxx +1 -0
- data/ext/couchbase/operations/bucket_get_all.hxx +1 -0
- data/ext/couchbase/operations/bucket_update.hxx +1 -0
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +1 -0
- data/ext/couchbase/operations/collection_create.hxx +6 -1
- data/ext/couchbase/operations/collection_drop.hxx +1 -0
- data/ext/couchbase/operations/command.hxx +86 -11
- data/ext/couchbase/operations/document_decrement.hxx +1 -0
- data/ext/couchbase/operations/document_exists.hxx +1 -0
- data/ext/couchbase/operations/document_get.hxx +1 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +1 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +1 -0
- data/ext/couchbase/operations/document_get_projected.hxx +243 -0
- data/ext/couchbase/operations/document_increment.hxx +4 -1
- data/ext/couchbase/operations/document_insert.hxx +1 -0
- data/ext/couchbase/operations/document_lookup_in.hxx +1 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +1 -0
- data/ext/couchbase/operations/document_query.hxx +13 -2
- data/ext/couchbase/operations/document_remove.hxx +1 -0
- data/ext/couchbase/operations/document_replace.hxx +1 -0
- data/ext/couchbase/operations/document_search.hxx +337 -0
- data/ext/couchbase/operations/document_touch.hxx +1 -0
- data/ext/couchbase/operations/document_unlock.hxx +1 -0
- data/ext/couchbase/operations/document_upsert.hxx +1 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +1 -0
- data/ext/couchbase/operations/query_index_create.hxx +1 -0
- data/ext/couchbase/operations/query_index_drop.hxx +1 -0
- data/ext/couchbase/operations/query_index_get_all.hxx +1 -0
- data/ext/couchbase/operations/scope_create.hxx +1 -0
- data/ext/couchbase/operations/scope_drop.hxx +1 -0
- data/ext/couchbase/operations/scope_get_all.hxx +2 -0
- data/ext/couchbase/operations/search_index.hxx +62 -0
- data/ext/couchbase/operations/search_index_analyze_document.hxx +92 -0
- data/ext/couchbase/operations/search_index_control_ingest.hxx +78 -0
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +80 -0
- data/ext/couchbase/operations/search_index_control_query.hxx +80 -0
- data/ext/couchbase/operations/search_index_drop.hxx +77 -0
- data/ext/couchbase/operations/search_index_get.hxx +80 -0
- data/ext/couchbase/operations/search_index_get_all.hxx +82 -0
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +81 -0
- data/ext/couchbase/operations/search_index_upsert.hxx +106 -0
- data/ext/couchbase/protocol/client_opcode.hxx +10 -0
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +117 -0
- data/ext/couchbase/timeout_defaults.hxx +32 -0
- data/ext/couchbase/version.hxx +1 -1
- data/ext/test/main.cxx +5 -5
- data/lib/couchbase/binary_collection.rb +16 -12
- data/lib/couchbase/binary_collection_options.rb +4 -0
- data/lib/couchbase/cluster.rb +88 -8
- data/lib/couchbase/collection.rb +39 -15
- data/lib/couchbase/collection_options.rb +19 -2
- data/lib/couchbase/json_transcoder.rb +2 -2
- data/lib/couchbase/management/bucket_manager.rb +37 -23
- data/lib/couchbase/management/collection_manager.rb +15 -6
- data/lib/couchbase/management/query_index_manager.rb +16 -6
- data/lib/couchbase/management/search_index_manager.rb +61 -14
- data/lib/couchbase/search_options.rb +1492 -0
- data/lib/couchbase/version.rb +1 -1
- metadata +22 -2
@@ -21,7 +21,7 @@ module Couchbase
|
|
21
21
|
class Collection
|
22
22
|
class GetOptions < CommonOptions
|
23
23
|
# @return [Boolean] if the expiration should also fetched with get
|
24
|
-
attr_accessor :
|
24
|
+
attr_accessor :with_expiration
|
25
25
|
|
26
26
|
# @return [JsonTranscoder] transcoder used for decoding
|
27
27
|
attr_accessor :transcoder
|
@@ -29,6 +29,9 @@ module Couchbase
|
|
29
29
|
# @yieldparam [GetOptions] self
|
30
30
|
def initialize
|
31
31
|
@transcoder = JsonTranscoder.new
|
32
|
+
@preserve_array_indexes = false
|
33
|
+
@with_expiration = nil
|
34
|
+
@projections = nil
|
32
35
|
yield self if block_given?
|
33
36
|
end
|
34
37
|
|
@@ -40,7 +43,21 @@ module Couchbase
|
|
40
43
|
# @param [String, Array<String>] paths a path that should be loaded if present.
|
41
44
|
def project(*paths)
|
42
45
|
@projections ||= []
|
43
|
-
@projections |= paths # union with current projections
|
46
|
+
@projections |= paths.flatten # union with current projections
|
47
|
+
end
|
48
|
+
|
49
|
+
# @api private
|
50
|
+
# @return [Boolean] whether to use sparse arrays (default false)
|
51
|
+
attr_accessor :preserve_array_indexes
|
52
|
+
|
53
|
+
# @api private
|
54
|
+
# @return [Array<String>] list of paths to project
|
55
|
+
attr_accessor :projections
|
56
|
+
|
57
|
+
# @api private
|
58
|
+
# @return [Boolean]
|
59
|
+
def need_projected_get?
|
60
|
+
@with_expiration || !@projections.nil?
|
44
61
|
end
|
45
62
|
end
|
46
63
|
|
@@ -22,11 +22,11 @@ module Couchbase
|
|
22
22
|
[JSON.generate(document), (0x02 << 24) | 0x06]
|
23
23
|
end
|
24
24
|
|
25
|
-
# @param [String] blob string of bytes, containing encoded representation of the document
|
25
|
+
# @param [String, nil] blob string of bytes, containing encoded representation of the document
|
26
26
|
# @param [Integer, :json] flags bit field, describing how the data encoded
|
27
27
|
# @return Object decoded document
|
28
28
|
def decode(blob, flags)
|
29
|
-
JSON.parse(blob)
|
29
|
+
JSON.parse(blob) unless blob.nil?
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -29,20 +29,25 @@ module Couchbase
|
|
29
29
|
# @param [BucketSettings] settings bucket settings
|
30
30
|
# @param [CreateBucketOptions] options
|
31
31
|
#
|
32
|
+
# @return void
|
33
|
+
#
|
32
34
|
# @raise [ArgumentError]
|
33
35
|
# @raise [Error::BucketExists]
|
34
36
|
def create_bucket(settings, options = CreateBucketOptions.new)
|
35
37
|
@backend.bucket_create(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
{
|
39
|
+
|
40
|
+
name: settings.name,
|
41
|
+
flush_enabled: settings.flush_enabled,
|
42
|
+
ram_quota_mb: settings.ram_quota_mb,
|
43
|
+
num_replicas: settings.num_replicas,
|
44
|
+
replica_indexes: settings.replica_indexes,
|
45
|
+
bucket_type: settings.bucket_type,
|
46
|
+
ejection_policy: settings.ejection_policy,
|
47
|
+
max_expiry: settings.max_expiry,
|
48
|
+
compression_mode: settings.compression_mode,
|
49
|
+
conflict_resolution_type: settings.conflict_resolution_type,
|
50
|
+
}, options.timeout
|
46
51
|
)
|
47
52
|
end
|
48
53
|
|
@@ -51,19 +56,23 @@ module Couchbase
|
|
51
56
|
# @param [BucketSettings] settings bucket settings
|
52
57
|
# @param [UpdateBucketOptions] options
|
53
58
|
#
|
59
|
+
# @return void
|
60
|
+
#
|
54
61
|
# @raise [ArgumentError]
|
55
62
|
# @raise [Error::BucketNotFound]
|
56
63
|
def update_bucket(settings, options = UpdateBucketOptions.new)
|
57
64
|
@backend.bucket_update(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
{
|
66
|
+
name: settings.name,
|
67
|
+
flush_enabled: settings.flush_enabled,
|
68
|
+
ram_quota_mb: settings.ram_quota_mb,
|
69
|
+
num_replicas: settings.num_replicas,
|
70
|
+
replica_indexes: settings.replica_indexes,
|
71
|
+
bucket_type: settings.bucket_type,
|
72
|
+
ejection_policy: settings.ejection_policy,
|
73
|
+
max_expiry: settings.max_expiry,
|
74
|
+
compression_mode: settings.compression_mode,
|
75
|
+
}, options.timeout
|
67
76
|
)
|
68
77
|
end
|
69
78
|
|
@@ -72,10 +81,12 @@ module Couchbase
|
|
72
81
|
# @param [String] bucket_name name of the bucket
|
73
82
|
# @param [DropBucketOptions] options
|
74
83
|
#
|
84
|
+
# @return void
|
85
|
+
#
|
75
86
|
# @raise [ArgumentError]
|
76
87
|
# @raise [Error::BucketNotFound]
|
77
88
|
def drop_bucket(bucket_name, options = DropBucketOptions.new)
|
78
|
-
@backend.bucket_drop(bucket_name)
|
89
|
+
@backend.bucket_drop(bucket_name, options.timeout)
|
79
90
|
end
|
80
91
|
|
81
92
|
# Fetch settings of the bucket
|
@@ -88,7 +99,7 @@ module Couchbase
|
|
88
99
|
# @raise [ArgumentError]
|
89
100
|
# @raise [Error::BucketNotFound]
|
90
101
|
def get_bucket(bucket_name, options = GetBucketOptions.new)
|
91
|
-
res = @backend.bucket_get(bucket_name)
|
102
|
+
res = @backend.bucket_get(bucket_name, options.timeout)
|
92
103
|
extract_bucket_settings(res)
|
93
104
|
end
|
94
105
|
|
@@ -97,16 +108,19 @@ module Couchbase
|
|
97
108
|
# @param [GetAllBucketsOptions] options
|
98
109
|
# @return [Array<BucketSettings>]
|
99
110
|
def get_all_buckets(options = GetAllBucketsOptions.new)
|
100
|
-
res = @backend.bucket_get_all
|
111
|
+
res = @backend.bucket_get_all(options.timeout)
|
101
112
|
res.map(&method(:extract_bucket_settings))
|
102
113
|
end
|
103
114
|
|
104
115
|
# @param [String] bucket_name name of the bucket
|
116
|
+
#
|
117
|
+
# @return void
|
118
|
+
#
|
105
119
|
# @raise [ArgumentError]
|
106
120
|
# @raise [Error::BucketNotFound]
|
107
121
|
# @raise [Error::BucketNotFlushable]
|
108
122
|
def flush_bucket(bucket_name, options = FlushBucketOptions.new)
|
109
|
-
@backend.bucket_flush(bucket_name)
|
123
|
+
@backend.bucket_flush(bucket_name, options.timeout)
|
110
124
|
end
|
111
125
|
|
112
126
|
class CreateBucketOptions
|
@@ -32,7 +32,7 @@ module Couchbase
|
|
32
32
|
#
|
33
33
|
# @return [Array<ScopeSpec>]
|
34
34
|
def get_all_scopes(options = GetAllScopesOptions.new)
|
35
|
-
res = @backend.scope_get_all(@bucket_name)
|
35
|
+
res = @backend.scope_get_all(@bucket_name, options.timeout)
|
36
36
|
res[:scopes].map do |s|
|
37
37
|
ScopeSpec.new do |scope|
|
38
38
|
scope.name = s[:name]
|
@@ -55,7 +55,8 @@ module Couchbase
|
|
55
55
|
#
|
56
56
|
# @raise [Error::ScopeNotFound]
|
57
57
|
def get_scope(scope_name, options = GetScopeOptions.new)
|
58
|
-
get_all_scopes.
|
58
|
+
get_all_scopes(GetAllScopesOptions.new {|o| o.timeout = options.timeout })
|
59
|
+
.find { |scope| scope.name == scope_name } or raise Error::ScopeNotFound, "unable to find scope #{scope_name}"
|
59
60
|
end
|
60
61
|
|
61
62
|
# Creates a new scope
|
@@ -63,9 +64,11 @@ module Couchbase
|
|
63
64
|
# @param [String] scope_name name of the scope
|
64
65
|
# @param [CreateScopeOptions] options
|
65
66
|
#
|
67
|
+
# @return void
|
68
|
+
#
|
66
69
|
# @raise [ArgumentError]
|
67
70
|
def create_scope(scope_name, options = CreateScopeOptions.new)
|
68
|
-
@backend.scope_create(@bucket_name, scope_name)
|
71
|
+
@backend.scope_create(@bucket_name, scope_name, options.timeout)
|
69
72
|
end
|
70
73
|
|
71
74
|
# Removes a scope
|
@@ -73,9 +76,11 @@ module Couchbase
|
|
73
76
|
# @param [String] scope_name name of the scope
|
74
77
|
# @param [DropScopeOptions] options
|
75
78
|
#
|
79
|
+
# @return void
|
80
|
+
#
|
76
81
|
# @raise [Error::ScopeNotFound]
|
77
82
|
def drop_scope(scope_name, options = DropScopeOptions.new)
|
78
|
-
@backend.scope_drop(@bucket_name, scope_name)
|
83
|
+
@backend.scope_drop(@bucket_name, scope_name, options.timeout)
|
79
84
|
end
|
80
85
|
|
81
86
|
# Creates a new collection
|
@@ -83,11 +88,13 @@ module Couchbase
|
|
83
88
|
# @param [CollectionSpec] collection specification of the collection
|
84
89
|
# @param [CreateCollectionOptions] options
|
85
90
|
#
|
91
|
+
# @return void
|
92
|
+
#
|
86
93
|
# @raise [ArgumentError]
|
87
94
|
# @raise [Error::CollectionExist]
|
88
95
|
# @raise [Error::ScopeNotFound]
|
89
96
|
def create_collection(collection, options = CreateCollectionOptions.new)
|
90
|
-
@backend.collection_create(@bucket_name, collection.scope_name, collection.name, collection.max_expiry)
|
97
|
+
@backend.collection_create(@bucket_name, collection.scope_name, collection.name, collection.max_expiry, options.timeout)
|
91
98
|
end
|
92
99
|
|
93
100
|
# Removes a collection
|
@@ -95,9 +102,11 @@ module Couchbase
|
|
95
102
|
# @param [CollectionSpec] collection specification of the collection
|
96
103
|
# @param [DropCollectionOptions] options
|
97
104
|
#
|
105
|
+
# @return void
|
106
|
+
#
|
98
107
|
# @raise [Error::CollectionNotFound]
|
99
108
|
def drop_collection(collection, options = DropCollectionOptions.new)
|
100
|
-
@backend.collection_drop(@bucket_name, collection.scope_name, collection.name)
|
109
|
+
@backend.collection_drop(@bucket_name, collection.scope_name, collection.name, options.timeout)
|
101
110
|
end
|
102
111
|
|
103
112
|
class GetScopeOptions
|
@@ -33,7 +33,7 @@ module Couchbase
|
|
33
33
|
#
|
34
34
|
# @raise [ArgumentError]
|
35
35
|
def get_all_indexes(bucket_name, options = GetAllIndexOptions.new)
|
36
|
-
res = @backend.query_index_get_all(bucket_name)
|
36
|
+
res = @backend.query_index_get_all(bucket_name, options.timeout)
|
37
37
|
res[:indexes].map do |idx|
|
38
38
|
QueryIndex.new do |index|
|
39
39
|
index.name = idx[:name]
|
@@ -55,6 +55,8 @@ module Couchbase
|
|
55
55
|
# @param [Array<String>] fields the lists of fields to create th index over
|
56
56
|
# @param [CreateIndexOptions] options
|
57
57
|
#
|
58
|
+
# @return void
|
59
|
+
#
|
58
60
|
# @raise [ArgumentError]
|
59
61
|
# @raise [Error::IndexExists]
|
60
62
|
def create_index(bucket_name, index_name, fields, options = CreateIndexOptions.new)
|
@@ -63,7 +65,7 @@ module Couchbase
|
|
63
65
|
condition: options.condition,
|
64
66
|
deferred: options.deferred,
|
65
67
|
num_replicas: options.num_replicas,
|
66
|
-
})
|
68
|
+
}, options.timeout)
|
67
69
|
end
|
68
70
|
|
69
71
|
# Creates new primary index
|
@@ -71,6 +73,8 @@ module Couchbase
|
|
71
73
|
# @param [String] bucket_name name of the bucket
|
72
74
|
# @param [CreatePrimaryIndexOptions] options
|
73
75
|
#
|
76
|
+
# @return void
|
77
|
+
#
|
74
78
|
# @raise [ArgumentError]
|
75
79
|
# @raise [Error::IndexExists]
|
76
80
|
def create_primary_index(bucket_name, options = CreatePrimaryIndexOptions.new)
|
@@ -78,7 +82,7 @@ module Couchbase
|
|
78
82
|
ignore_if_exists: options.ignore_if_exists,
|
79
83
|
deferred: options.deferred,
|
80
84
|
num_replicas: options.num_replicas,
|
81
|
-
})
|
85
|
+
}, options.timeout)
|
82
86
|
end
|
83
87
|
|
84
88
|
# Drops the index
|
@@ -87,12 +91,14 @@ module Couchbase
|
|
87
91
|
# @param [String] index_name name of the index
|
88
92
|
# @param [DropIndexOptions] options
|
89
93
|
#
|
94
|
+
# @return void
|
95
|
+
#
|
90
96
|
# @raise [ArgumentError]
|
91
97
|
# @raise [Error::IndexNotFound]
|
92
98
|
def drop_index(bucket_name, index_name, options = DropIndexOptions.new)
|
93
99
|
@backend.query_index_drop(bucket_name, index_name, {
|
94
100
|
ignore_if_does_not_exist: options.ignore_if_does_not_exist,
|
95
|
-
})
|
101
|
+
}, options.timeout)
|
96
102
|
true
|
97
103
|
end
|
98
104
|
|
@@ -101,13 +107,15 @@ module Couchbase
|
|
101
107
|
# @param [String] bucket_name name of the bucket
|
102
108
|
# @param [DropPrimaryIndexOptions] options
|
103
109
|
#
|
110
|
+
# @return void
|
111
|
+
#
|
104
112
|
# @raise [ArgumentError]
|
105
113
|
# @raise [Error::IndexNotFound]
|
106
114
|
def drop_primary_index(bucket_name, options = DropPrimaryIndexOptions.new)
|
107
115
|
@backend.query_index_drop_primary(bucket_name, {
|
108
116
|
ignore_if_does_not_exist: options.ignore_if_does_not_exist,
|
109
117
|
index_name: options.index_name,
|
110
|
-
})
|
118
|
+
}, options.timeout)
|
111
119
|
true
|
112
120
|
end
|
113
121
|
|
@@ -116,9 +124,11 @@ module Couchbase
|
|
116
124
|
# @param [String] bucket_name name of the bucket
|
117
125
|
# @param [BuildDeferredIndexOptions] options
|
118
126
|
#
|
127
|
+
# @return void
|
128
|
+
#
|
119
129
|
# @raise [ArgumentError]
|
120
130
|
def build_deferred_indexes(bucket_name, options = BuildDeferredIndexOptions.new)
|
121
|
-
@backend.query_index_build_deferred(bucket_name,
|
131
|
+
@backend.query_index_build_deferred(bucket_name, options.timeout)
|
122
132
|
end
|
123
133
|
|
124
134
|
# Polls indexes until they are online
|
@@ -34,7 +34,8 @@ module Couchbase
|
|
34
34
|
# @raise [ArgumentError]
|
35
35
|
# @raise [Error::IndexNotFound]
|
36
36
|
def get_index(index_name, options = GetIndexOptions.new)
|
37
|
-
|
37
|
+
res = @backend.search_index_get(index_name, options.timeout)
|
38
|
+
extract_search_index(res)
|
38
39
|
end
|
39
40
|
|
40
41
|
# Fetches all indexes from the server
|
@@ -43,7 +44,8 @@ module Couchbase
|
|
43
44
|
#
|
44
45
|
# @return [Array<SearchIndex>]
|
45
46
|
def get_all_indexes(options = GetAllIndexesOptions.new)
|
46
|
-
|
47
|
+
res = @backend.search_index_get_all(options.timeout)
|
48
|
+
res[:indexes].map { |idx| extract_search_index(idx) }
|
47
49
|
end
|
48
50
|
|
49
51
|
# Creates or updates the index
|
@@ -51,9 +53,22 @@ module Couchbase
|
|
51
53
|
# @param [SearchIndex] index_definition the index definition
|
52
54
|
# @param [UpsertIndexOptions] options
|
53
55
|
#
|
56
|
+
# @return void
|
57
|
+
#
|
54
58
|
# @raise [ArgumentError] if name, type or source_type is empty
|
55
59
|
def upsert_index(index_definition, options = UpsertIndexOptions.new)
|
56
|
-
|
60
|
+
@backend.search_index_upsert(
|
61
|
+
{
|
62
|
+
name: index_definition.name,
|
63
|
+
type: index_definition.type,
|
64
|
+
uuid: index_definition.uuid,
|
65
|
+
params: (JSON.generate(index_definition.params) if index_definition.params),
|
66
|
+
source_name: index_definition.source_name,
|
67
|
+
source_type: index_definition.source_type,
|
68
|
+
source_uuid: index_definition.source_uuid,
|
69
|
+
source_params: (JSON.generate(index_definition.source_params) if index_definition.source_params),
|
70
|
+
plan_params: (JSON.generate(index_definition.plan_params) if index_definition.plan_params),
|
71
|
+
}, options.timeout)
|
57
72
|
end
|
58
73
|
|
59
74
|
# Drops the index
|
@@ -61,23 +76,26 @@ module Couchbase
|
|
61
76
|
# @param [String] index_name name of the index
|
62
77
|
# @param [DropIndexOptions] options
|
63
78
|
#
|
79
|
+
# @return void
|
80
|
+
#
|
64
81
|
# @raise [ArgumentError]
|
65
82
|
# @raise [Error::IndexNotFound]
|
66
83
|
def drop_index(index_name, options = DropIndexOptions.new)
|
67
|
-
|
84
|
+
@backend.search_index_drop(index_name, options.timeout)
|
68
85
|
end
|
69
86
|
|
70
87
|
# Retrieves the number of documents that have been indexed for an index
|
71
88
|
#
|
72
89
|
# @param [String] index_name name of the index
|
73
|
-
# @param [
|
90
|
+
# @param [GetIndexedDocumentsCountOptions] options
|
74
91
|
#
|
75
92
|
# @return [Integer]
|
76
93
|
#
|
77
94
|
# @raise [ArgumentError]
|
78
95
|
# @raise [Error::IndexNotFound]
|
79
96
|
def get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new)
|
80
|
-
|
97
|
+
res = @backend.search_index_get_documents_count(index_name, options.timeout)
|
98
|
+
res[:count]
|
81
99
|
end
|
82
100
|
|
83
101
|
# Pauses updates and maintenance for the index
|
@@ -85,10 +103,12 @@ module Couchbase
|
|
85
103
|
# @param [String] index_name name of the index
|
86
104
|
# @param [PauseIngestOptions] options
|
87
105
|
#
|
106
|
+
# @return void
|
107
|
+
#
|
88
108
|
# @raise [ArgumentError]
|
89
109
|
# @raise [Error::IndexNotFound]
|
90
110
|
def pause_ingest(index_name, options = PauseIngestOptions.new)
|
91
|
-
|
111
|
+
@backend.search_index_pause_ingest(index_name, options.timeout)
|
92
112
|
end
|
93
113
|
|
94
114
|
# Resumes updates and maintenance for an index
|
@@ -96,10 +116,12 @@ module Couchbase
|
|
96
116
|
# @param [String] index_name name of the index
|
97
117
|
# @param [ResumeIngestOptions] options
|
98
118
|
#
|
119
|
+
# @return void
|
120
|
+
#
|
99
121
|
# @raise [ArgumentError]
|
100
122
|
# @raise [Error::IndexNotFound]
|
101
123
|
def resume_ingest(index_name, options = ResumeIngestOptions.new)
|
102
|
-
|
124
|
+
@backend.search_index_resume_ingest(index_name, options.timeout)
|
103
125
|
end
|
104
126
|
|
105
127
|
# Allows querying against the index
|
@@ -107,10 +129,12 @@ module Couchbase
|
|
107
129
|
# @param [String] index_name name of the index
|
108
130
|
# @param [AllowQueryingOptions] options
|
109
131
|
#
|
132
|
+
# @return void
|
133
|
+
#
|
110
134
|
# @raise [ArgumentError]
|
111
135
|
# @raise [Error::IndexNotFound]
|
112
136
|
def allow_querying(index_name, options = AllowQueryingOptions.new)
|
113
|
-
|
137
|
+
@backend.search_index_allow_querying(index_name, options.timeout)
|
114
138
|
end
|
115
139
|
|
116
140
|
# Disallows querying against the index
|
@@ -118,10 +142,12 @@ module Couchbase
|
|
118
142
|
# @param [String] index_name name of the index
|
119
143
|
# @param [DisallowQueryingOptions] options
|
120
144
|
#
|
145
|
+
# @return void
|
146
|
+
#
|
121
147
|
# @raise [ArgumentError]
|
122
148
|
# @raise [Error::IndexNotFound]
|
123
149
|
def disallow_querying(index_name, options = DisallowQueryingOptions.new)
|
124
|
-
|
150
|
+
@backend.search_index_disallow_querying(index_name, options.timeout)
|
125
151
|
end
|
126
152
|
|
127
153
|
# Freeze the assignment of index partitions to nodes
|
@@ -129,10 +155,12 @@ module Couchbase
|
|
129
155
|
# @param [String] index_name name of the index
|
130
156
|
# @param [FreezePlanOptions] options
|
131
157
|
#
|
158
|
+
# @return void
|
159
|
+
#
|
132
160
|
# @raise [ArgumentError]
|
133
161
|
# @raise [Error::IndexNotFound]
|
134
162
|
def freeze_plan(index_name, options = FreezePlanOptions.new)
|
135
|
-
|
163
|
+
@backend.search_index_freeze_plan(index_name, options.timeout)
|
136
164
|
end
|
137
165
|
|
138
166
|
# Unfreeze the assignment of index partitions to nodes
|
@@ -140,10 +168,12 @@ module Couchbase
|
|
140
168
|
# @param [String] index_name name of the index
|
141
169
|
# @param [UnfreezePlanOptions] options
|
142
170
|
#
|
171
|
+
# @return void
|
172
|
+
#
|
143
173
|
# @raise [ArgumentError]
|
144
174
|
# @raise [Error::IndexNotFound]
|
145
175
|
def unfreeze_plan(index_name, options = UnfreezePlanOptions.new)
|
146
|
-
|
176
|
+
@backend.search_index_unfreeze_plan(index_name, options.timeout)
|
147
177
|
end
|
148
178
|
|
149
179
|
# Allows to see how a document is analyzed against a specific index
|
@@ -156,7 +186,8 @@ module Couchbase
|
|
156
186
|
# @raise [ArgumentError]
|
157
187
|
# @raise [Error::IndexNotFound]
|
158
188
|
def analyze_document(index_name, document, options = AnalyzeDocumentOptions.new)
|
159
|
-
|
189
|
+
res = @backend.search_index_analyze_document(index_name, JSON.generate(document), options.timeout)
|
190
|
+
JSON.parse(res[:analysis])
|
160
191
|
end
|
161
192
|
|
162
193
|
class GetIndexOptions
|
@@ -199,7 +230,7 @@ module Couchbase
|
|
199
230
|
end
|
200
231
|
end
|
201
232
|
|
202
|
-
class
|
233
|
+
class GetIndexedDocumentsCountOptions
|
203
234
|
# @return [Integer] the time in milliseconds allowed for the operation to complete
|
204
235
|
attr_accessor :timeout
|
205
236
|
|
@@ -278,6 +309,22 @@ module Couchbase
|
|
278
309
|
yield self if block_given?
|
279
310
|
end
|
280
311
|
end
|
312
|
+
|
313
|
+
private
|
314
|
+
|
315
|
+
def extract_search_index(resp)
|
316
|
+
SearchIndex.new do |index|
|
317
|
+
index.name = resp[:name]
|
318
|
+
index.type = resp[:type]
|
319
|
+
index.uuid = resp[:uuid]
|
320
|
+
index.params = resp[:params] ? JSON.parse(resp[:params]) : {}
|
321
|
+
index.source_name = resp[:source_name]
|
322
|
+
index.source_type = resp[:source_type]
|
323
|
+
index.source_uuid = resp[:source_uuid]
|
324
|
+
index.source_params = resp[:source_params] ? JSON.parse(resp[:source_params]) : {}
|
325
|
+
index.plan_params = resp[:plan_params] ? JSON.parse(resp[:plan_params]) : {}
|
326
|
+
end
|
327
|
+
end
|
281
328
|
end
|
282
329
|
|
283
330
|
class SearchIndex
|