gcloud 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/AUTHENTICATION.md +13 -9
- data/CHANGELOG.md +8 -3
- data/OVERVIEW.md +46 -8
- data/lib/gcloud.rb +123 -117
- data/lib/gcloud/backoff.rb +43 -15
- data/lib/gcloud/bigquery.rb +211 -195
- data/lib/gcloud/bigquery/connection.rb +9 -9
- data/lib/gcloud/bigquery/copy_job.rb +15 -16
- data/lib/gcloud/bigquery/credentials.rb +3 -3
- data/lib/gcloud/bigquery/data.rb +12 -11
- data/lib/gcloud/bigquery/dataset.rb +162 -216
- data/lib/gcloud/bigquery/dataset/access.rb +59 -43
- data/lib/gcloud/bigquery/dataset/list.rb +3 -3
- data/lib/gcloud/bigquery/errors.rb +9 -5
- data/lib/gcloud/bigquery/extract_job.rb +18 -18
- data/lib/gcloud/bigquery/insert_response.rb +7 -4
- data/lib/gcloud/bigquery/job.rb +48 -44
- data/lib/gcloud/bigquery/job/list.rb +3 -3
- data/lib/gcloud/bigquery/load_job.rb +24 -25
- data/lib/gcloud/bigquery/project.rb +145 -204
- data/lib/gcloud/bigquery/query_data.rb +10 -9
- data/lib/gcloud/bigquery/query_job.rb +23 -32
- data/lib/gcloud/bigquery/table.rb +238 -280
- data/lib/gcloud/bigquery/table/list.rb +3 -3
- data/lib/gcloud/bigquery/table/schema.rb +79 -87
- data/lib/gcloud/bigquery/view.rb +69 -82
- data/lib/gcloud/credentials.rb +3 -9
- data/lib/gcloud/datastore.rb +194 -170
- data/lib/gcloud/datastore/connection.rb +12 -8
- data/lib/gcloud/datastore/credentials.rb +6 -4
- data/lib/gcloud/datastore/dataset.rb +74 -141
- data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
- data/lib/gcloud/datastore/entity.rb +81 -76
- data/lib/gcloud/datastore/errors.rb +10 -8
- data/lib/gcloud/datastore/key.rb +41 -77
- data/lib/gcloud/datastore/properties.rb +3 -3
- data/lib/gcloud/datastore/proto.rb +7 -4
- data/lib/gcloud/datastore/query.rb +26 -3
- data/lib/gcloud/datastore/transaction.rb +12 -8
- data/lib/gcloud/dns.rb +180 -152
- data/lib/gcloud/dns/change.rb +16 -16
- data/lib/gcloud/dns/change/list.rb +3 -3
- data/lib/gcloud/dns/connection.rb +9 -10
- data/lib/gcloud/dns/credentials.rb +3 -3
- data/lib/gcloud/dns/errors.rb +9 -5
- data/lib/gcloud/dns/importer.rb +17 -23
- data/lib/gcloud/dns/project.rb +42 -64
- data/lib/gcloud/dns/record.rb +58 -46
- data/lib/gcloud/dns/record/list.rb +6 -7
- data/lib/gcloud/dns/zone.rb +198 -289
- data/lib/gcloud/dns/zone/list.rb +3 -3
- data/lib/gcloud/dns/zone/transaction.rb +56 -72
- data/lib/gcloud/errors.rb +174 -3
- data/lib/gcloud/gce.rb +3 -4
- data/lib/gcloud/grpc_utils.rb +76 -0
- data/lib/gcloud/logging.rb +308 -0
- data/lib/gcloud/logging/credentials.rb +29 -0
- data/lib/gcloud/logging/entry.rb +303 -0
- data/lib/gcloud/logging/entry/http_request.rb +141 -0
- data/lib/gcloud/logging/entry/list.rb +111 -0
- data/lib/gcloud/logging/entry/operation.rb +90 -0
- data/lib/gcloud/logging/logger.rb +307 -0
- data/lib/gcloud/logging/metric.rb +175 -0
- data/lib/gcloud/logging/metric/list.rb +98 -0
- data/lib/gcloud/logging/project.rb +650 -0
- data/lib/gcloud/logging/resource.rb +95 -0
- data/lib/gcloud/logging/resource_descriptor.rb +140 -0
- data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
- data/lib/gcloud/logging/service.rb +258 -0
- data/lib/gcloud/logging/sink.rb +233 -0
- data/lib/gcloud/logging/sink/list.rb +97 -0
- data/lib/gcloud/pubsub.rb +241 -199
- data/lib/gcloud/pubsub/credentials.rb +3 -3
- data/lib/gcloud/pubsub/message.rb +26 -20
- data/lib/gcloud/pubsub/project.rb +166 -233
- data/lib/gcloud/pubsub/received_message.rb +28 -38
- data/lib/gcloud/pubsub/service.rb +323 -0
- data/lib/gcloud/pubsub/subscription.rb +172 -242
- data/lib/gcloud/pubsub/subscription/list.rb +11 -9
- data/lib/gcloud/pubsub/topic.rb +152 -271
- data/lib/gcloud/pubsub/topic/batch.rb +66 -0
- data/lib/gcloud/pubsub/topic/list.rb +9 -7
- data/lib/gcloud/resource_manager.rb +158 -138
- data/lib/gcloud/resource_manager/connection.rb +6 -5
- data/lib/gcloud/resource_manager/credentials.rb +3 -3
- data/lib/gcloud/resource_manager/errors.rb +9 -5
- data/lib/gcloud/resource_manager/manager.rb +54 -86
- data/lib/gcloud/resource_manager/project.rb +69 -88
- data/lib/gcloud/resource_manager/project/list.rb +4 -5
- data/lib/gcloud/resource_manager/project/updater.rb +12 -14
- data/lib/gcloud/search.rb +158 -135
- data/lib/gcloud/search/api_client.rb +7 -7
- data/lib/gcloud/search/connection.rb +8 -8
- data/lib/gcloud/search/credentials.rb +3 -3
- data/lib/gcloud/search/document.rb +64 -87
- data/lib/gcloud/search/document/list.rb +5 -5
- data/lib/gcloud/search/errors.rb +9 -5
- data/lib/gcloud/search/field_value.rb +32 -38
- data/lib/gcloud/search/field_values.rb +50 -80
- data/lib/gcloud/search/fields.rb +44 -65
- data/lib/gcloud/search/index.rb +163 -204
- data/lib/gcloud/search/index/list.rb +5 -5
- data/lib/gcloud/search/project.rb +31 -47
- data/lib/gcloud/search/result.rb +27 -31
- data/lib/gcloud/search/result/list.rb +6 -6
- data/lib/gcloud/storage.rb +224 -190
- data/lib/gcloud/storage/bucket.rb +202 -227
- data/lib/gcloud/storage/bucket/acl.rb +83 -170
- data/lib/gcloud/storage/bucket/cors.rb +31 -34
- data/lib/gcloud/storage/bucket/list.rb +3 -3
- data/lib/gcloud/storage/connection.rb +11 -7
- data/lib/gcloud/storage/credentials.rb +3 -3
- data/lib/gcloud/storage/errors.rb +11 -8
- data/lib/gcloud/storage/file.rb +129 -171
- data/lib/gcloud/storage/file/acl.rb +51 -99
- data/lib/gcloud/storage/file/list.rb +3 -3
- data/lib/gcloud/storage/file/verifier.rb +3 -2
- data/lib/gcloud/storage/project.rb +111 -132
- data/lib/gcloud/upload.rb +4 -7
- data/lib/gcloud/version.rb +2 -4
- data/lib/google/api/annotations.rb +14 -0
- data/lib/google/api/http.rb +30 -0
- data/lib/google/api/label.rb +24 -0
- data/lib/google/api/monitored_resource.rb +25 -0
- data/lib/google/datastore/v1beta3/datastore.rb +115 -0
- data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
- data/lib/google/datastore/v1beta3/entity.rb +63 -0
- data/lib/google/datastore/v1beta3/query.rb +128 -0
- data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
- data/lib/google/example/library/v1/library.rb +91 -0
- data/lib/google/example/library/v1/library_services.rb +40 -0
- data/lib/google/iam/v1/iam_policy.rb +33 -0
- data/lib/google/iam/v1/iam_policy_services.rb +30 -0
- data/lib/google/iam/v1/policy.rb +25 -0
- data/lib/google/logging/type/http_request.rb +28 -0
- data/lib/google/logging/type/log_severity.rb +27 -0
- data/lib/google/logging/v2/log_entry.rb +44 -0
- data/lib/google/logging/v2/logging.rb +56 -0
- data/lib/google/logging/v2/logging_config.rb +59 -0
- data/lib/google/logging/v2/logging_config_services.rb +32 -0
- data/lib/google/logging/v2/logging_metrics.rb +51 -0
- data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
- data/lib/google/logging/v2/logging_services.rb +31 -0
- data/lib/google/longrunning/operations.rb +50 -0
- data/lib/google/longrunning/operations_services.rb +29 -0
- data/lib/google/protobuf/any.rb +17 -0
- data/lib/google/protobuf/api.rb +31 -0
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/protobuf/duration.rb +17 -0
- data/lib/google/protobuf/empty.rb +15 -0
- data/lib/google/protobuf/field_mask.rb +16 -0
- data/lib/google/protobuf/source_context.rb +16 -0
- data/lib/google/protobuf/struct.rb +35 -0
- data/lib/google/protobuf/timestamp.rb +17 -0
- data/lib/google/protobuf/type.rb +79 -0
- data/lib/google/protobuf/wrappers.rb +48 -0
- data/lib/google/pubsub/v1/pubsub.rb +129 -0
- data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
- data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
- data/lib/google/rpc/code.rb +32 -0
- data/lib/google/rpc/error_details.rb +61 -0
- data/lib/google/rpc/status.rb +19 -0
- data/lib/google/type/color.rb +20 -0
- data/lib/google/type/date.rb +18 -0
- data/lib/google/type/dayofweek.rb +23 -0
- data/lib/google/type/latlng.rb +17 -0
- data/lib/google/type/money.rb +18 -0
- data/lib/google/type/timeofday.rb +19 -0
- metadata +101 -4
- data/lib/gcloud/pubsub/connection.rb +0 -295
- data/lib/gcloud/pubsub/errors.rb +0 -93
data/lib/gcloud/search/index.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
# Copyright 2015 Google Inc. All rights reserved.
|
3
2
|
#
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -13,6 +12,7 @@
|
|
13
12
|
# See the License for the specific language governing permissions and
|
14
13
|
# limitations under the License.
|
15
14
|
|
15
|
+
|
16
16
|
require "gcloud/search/document"
|
17
17
|
require "gcloud/search/index/list"
|
18
18
|
require "gcloud/search/result"
|
@@ -20,17 +20,20 @@ require "gcloud/search/result"
|
|
20
20
|
module Gcloud
|
21
21
|
module Search
|
22
22
|
##
|
23
|
-
#
|
23
|
+
# # Index
|
24
24
|
#
|
25
|
-
# An index manages Document instances for retrieval. Indexes cannot be
|
25
|
+
# An index manages {Document} instances for retrieval. Indexes cannot be
|
26
26
|
# created, updated, or deleted directly on the server: They are derived from
|
27
27
|
# the documents that reference them. You can manage groups of documents by
|
28
28
|
# putting them into separate indexes.
|
29
29
|
#
|
30
|
-
# With an index, you can retrieve documents with
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# With an index, you can retrieve documents with
|
31
|
+
# {Gcloud::Search::Index#find} and {Gcloud::Search::Index#documents}; manage
|
32
|
+
# them with {Gcloud::Search::Index#document}, {Gcloud::Search::Index#save},
|
33
|
+
# and {Gcloud::Search::Index#remove}; and perform searches over their fields
|
34
|
+
# with {Gcloud::Search::Index#search}.
|
33
35
|
#
|
36
|
+
# @example
|
34
37
|
# require "gcloud"
|
35
38
|
#
|
36
39
|
# gcloud = Gcloud.new
|
@@ -42,22 +45,22 @@ module Gcloud
|
|
42
45
|
# puts result.doc_id
|
43
46
|
# end
|
44
47
|
#
|
45
|
-
#
|
46
|
-
#
|
48
|
+
# @see https://cloud.google.com/search/documents_indexes Documents and
|
49
|
+
# Indexes
|
47
50
|
#
|
48
51
|
class Index
|
49
52
|
##
|
50
|
-
# The Connection object.
|
51
|
-
attr_accessor :connection
|
53
|
+
# @private The Connection object.
|
54
|
+
attr_accessor :connection
|
52
55
|
|
53
56
|
##
|
54
|
-
# The raw data object.
|
55
|
-
attr_accessor :raw
|
57
|
+
# @private The raw data object.
|
58
|
+
attr_accessor :raw
|
56
59
|
|
57
60
|
##
|
58
|
-
# Creates a new Index instance.
|
61
|
+
# @private Creates a new Index instance.
|
59
62
|
#
|
60
|
-
def initialize
|
63
|
+
def initialize
|
61
64
|
@connection = nil
|
62
65
|
@raw = nil
|
63
66
|
end
|
@@ -74,48 +77,54 @@ module Gcloud
|
|
74
77
|
end
|
75
78
|
|
76
79
|
##
|
77
|
-
# The names of fields in which TEXT values are stored.
|
78
|
-
#
|
80
|
+
# The names of fields in which TEXT values are stored.
|
81
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
82
|
+
# Index schemas
|
79
83
|
def text_fields
|
80
84
|
return @raw["indexedField"]["textFields"] if @raw["indexedField"]
|
81
85
|
[]
|
82
86
|
end
|
83
87
|
|
84
88
|
##
|
85
|
-
# The names of fields in which HTML values are stored.
|
86
|
-
#
|
89
|
+
# The names of fields in which HTML values are stored.
|
90
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
91
|
+
# Index schemas
|
87
92
|
def html_fields
|
88
93
|
return @raw["indexedField"]["htmlFields"] if @raw["indexedField"]
|
89
94
|
[]
|
90
95
|
end
|
91
96
|
|
92
97
|
##
|
93
|
-
# The names of fields in which ATOM values are stored.
|
94
|
-
#
|
98
|
+
# The names of fields in which ATOM values are stored.
|
99
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
100
|
+
# Index schemas
|
95
101
|
def atom_fields
|
96
102
|
return @raw["indexedField"]["atomFields"] if @raw["indexedField"]
|
97
103
|
[]
|
98
104
|
end
|
99
105
|
|
100
106
|
##
|
101
|
-
# The names of fields in which DATE values are stored.
|
102
|
-
#
|
107
|
+
# The names of fields in which DATE values are stored.
|
108
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
109
|
+
# Index schemas
|
103
110
|
def datetime_fields
|
104
111
|
return @raw["indexedField"]["dateFields"] if @raw["indexedField"]
|
105
112
|
[]
|
106
113
|
end
|
107
114
|
|
108
115
|
##
|
109
|
-
# The names of fields in which NUMBER values are stored.
|
110
|
-
#
|
116
|
+
# The names of fields in which NUMBER values are stored.
|
117
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
118
|
+
# Index schemas
|
111
119
|
def number_fields
|
112
120
|
return @raw["indexedField"]["numberFields"] if @raw["indexedField"]
|
113
121
|
[]
|
114
122
|
end
|
115
123
|
|
116
124
|
##
|
117
|
-
# The names of fields in which GEO values are stored.
|
118
|
-
#
|
125
|
+
# The names of fields in which GEO values are stored.
|
126
|
+
# @see https://cloud.google.com/search/documents_indexes#index_schemas
|
127
|
+
# Index schemas
|
119
128
|
def geo_fields
|
120
129
|
return @raw["indexedField"]["geoFields"] if @raw["indexedField"]
|
121
130
|
[]
|
@@ -144,17 +153,12 @@ module Gcloud
|
|
144
153
|
##
|
145
154
|
# Retrieves an existing document by id.
|
146
155
|
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
# === Returns
|
153
|
-
#
|
154
|
-
# Gcloud::Search::Document or +nil+ if the document does not exist
|
155
|
-
#
|
156
|
-
# === Example
|
156
|
+
# @param [String, Gcloud::Search::Document] doc_id The id of a document or
|
157
|
+
# a Document instance.
|
158
|
+
# @return [Gcloud::Search::Document, nil] Returns `nil` if the document
|
159
|
+
# does not exist
|
157
160
|
#
|
161
|
+
# @example
|
158
162
|
# require "gcloud"
|
159
163
|
#
|
160
164
|
# gcloud = Gcloud.new
|
@@ -179,36 +183,30 @@ module Gcloud
|
|
179
183
|
|
180
184
|
##
|
181
185
|
# Helper for creating a new Document instance. The returned instance is
|
182
|
-
# local: It is either not yet saved to the service (see
|
183
|
-
# has been given the id of an
|
184
|
-
# with the document's data (see
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
# === Returns
|
207
|
-
#
|
208
|
-
# Gcloud::Search::Document
|
209
|
-
#
|
210
|
-
# === Example
|
211
|
-
#
|
186
|
+
# local: It is either not yet saved to the service (see
|
187
|
+
# {Gcloud::Search::Index#save}), or if it has been given the id of an
|
188
|
+
# existing document, it is not yet populated with the document's data (see
|
189
|
+
# {Gcloud::Search::Index#find}).
|
190
|
+
#
|
191
|
+
# @param [String, nil] doc_id An optional unique ID for the new document.
|
192
|
+
# When the document is saved, this value must contain only visible,
|
193
|
+
# printable ASCII characters (ASCII codes 33 through 126 inclusive) and
|
194
|
+
# be no longer than 500 characters. It cannot begin with an exclamation
|
195
|
+
# point (<code>!</code>), and it cannot begin and end with double
|
196
|
+
# underscores (<code>__</code>).
|
197
|
+
# @param [Integer, nil] rank An optional rank for the new document. An
|
198
|
+
# integer which determines the default ordering of documents returned
|
199
|
+
# from a search. It is a bad idea to assign the same rank to many
|
200
|
+
# documents, and the same rank should never be assigned to more than
|
201
|
+
# 10,000 documents. By default (when it is not specified or set to 0),
|
202
|
+
# it is set at the time the document is saved to the number of seconds
|
203
|
+
# since January 1, 2011. The rank can be used in the `expressions`,
|
204
|
+
# `order`, and `fields` options in {Gcloud::Search::Index#search}, where
|
205
|
+
# it should referenced as `rank`.
|
206
|
+
#
|
207
|
+
# @return [Gcloud::Search::Document]
|
208
|
+
#
|
209
|
+
# @example
|
212
210
|
# require "gcloud"
|
213
211
|
#
|
214
212
|
# gcloud = Gcloud.new
|
@@ -219,9 +217,7 @@ module Gcloud
|
|
219
217
|
# document.doc_id #=> nil
|
220
218
|
# document.rank #=> nil
|
221
219
|
#
|
222
|
-
# To check if an index already contains a document
|
223
|
-
# the instance to #find:
|
224
|
-
#
|
220
|
+
# @example To check if an index already contains a document:
|
225
221
|
# require "gcloud"
|
226
222
|
#
|
227
223
|
# gcloud = Gcloud.new
|
@@ -241,21 +237,14 @@ module Gcloud
|
|
241
237
|
##
|
242
238
|
# Retrieves the list of documents belonging to the index.
|
243
239
|
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
# Maximum number of documents to return. The default is +100+.
|
251
|
-
# (+Integer+)
|
252
|
-
#
|
253
|
-
# === Returns
|
254
|
-
#
|
255
|
-
# Array of Gcloud::Search::Document (See Gcloud::Search::Document::List)
|
256
|
-
#
|
257
|
-
# === Examples
|
240
|
+
# @param [String] token A previously-returned page token representing part
|
241
|
+
# of the larger set of results to view.
|
242
|
+
# @param [Integer] max Maximum number of documents to return. The default
|
243
|
+
# is `100`.
|
244
|
+
# @return [Array<Gcloud::Search::Document>] See
|
245
|
+
# {Gcloud::Search::Document::List})
|
258
246
|
#
|
247
|
+
# @example
|
259
248
|
# require "gcloud"
|
260
249
|
#
|
261
250
|
# gcloud = Gcloud.new
|
@@ -267,9 +256,7 @@ module Gcloud
|
|
267
256
|
# puts index.index_id
|
268
257
|
# end
|
269
258
|
#
|
270
|
-
#
|
271
|
-
# through them: (See Gcloud::Search::Document::List)
|
272
|
-
#
|
259
|
+
# @example With pagination: (See {Gcloud::Search::Document::List})
|
273
260
|
# require "gcloud"
|
274
261
|
#
|
275
262
|
# gcloud = Gcloud.new
|
@@ -295,21 +282,17 @@ module Gcloud
|
|
295
282
|
|
296
283
|
##
|
297
284
|
# Saves a new or existing document to the index. If the document instance
|
298
|
-
# is new and has been given an id (see #document),
|
299
|
-
# existing document in the index that has the same
|
285
|
+
# is new and has been given an id (see {Gcloud::Search::Index#document}),
|
286
|
+
# it will replace an existing document in the index that has the same
|
287
|
+
# unique id.
|
300
288
|
#
|
301
|
-
#
|
289
|
+
# @param [Gcloud::Search::Document] document A Document instance, either
|
290
|
+
# new (see {Gcloud::Search::Index#document}) or existing (see
|
291
|
+
# {Gcloud::Search::Index#find}).
|
302
292
|
#
|
303
|
-
#
|
304
|
-
# A Document instance, either new (see #document) or existing (see
|
305
|
-
# #find).
|
306
|
-
#
|
307
|
-
# === Returns
|
308
|
-
#
|
309
|
-
# Gcloud::Search::Document
|
310
|
-
#
|
311
|
-
# === Example
|
293
|
+
# @return [Gcloud::Search::Document]
|
312
294
|
#
|
295
|
+
# @example
|
313
296
|
# require "gcloud"
|
314
297
|
#
|
315
298
|
# gcloud = Gcloud.new
|
@@ -340,17 +323,10 @@ module Gcloud
|
|
340
323
|
##
|
341
324
|
# Permanently deletes the document from the index.
|
342
325
|
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
# +doc_id+::
|
346
|
-
# The id of the document. (+String+)
|
347
|
-
#
|
348
|
-
# === Returns
|
349
|
-
#
|
350
|
-
# +true+ if successful
|
351
|
-
#
|
352
|
-
# === Example
|
326
|
+
# @param [String] doc_id The id of the document.
|
327
|
+
# @return [Boolean] `true` if successful
|
353
328
|
#
|
329
|
+
# @example
|
354
330
|
# require "gcloud"
|
355
331
|
#
|
356
332
|
# gcloud = Gcloud.new
|
@@ -373,24 +349,19 @@ module Gcloud
|
|
373
349
|
# be created, updated, or deleted directly on the server: They are derived
|
374
350
|
# from the documents that reference them.)
|
375
351
|
#
|
376
|
-
#
|
377
|
-
#
|
378
|
-
#
|
379
|
-
# If +true+, ensures the deletion of the index by first deleting all
|
380
|
-
# documents. If +false+ and the index contains documents, the request
|
381
|
-
# will fail. Default is +false+. (+Boolean+)
|
382
|
-
#
|
383
|
-
# === Examples
|
352
|
+
# @param [Boolean] force If `true`, ensures the deletion of the index by
|
353
|
+
# first deleting all documents. If `false` and the index contains
|
354
|
+
# documents, the request will fail. Default is `false`.
|
384
355
|
#
|
356
|
+
# @example
|
385
357
|
# require "gcloud"
|
386
358
|
#
|
387
359
|
# gcloud = Gcloud.new
|
388
360
|
# search = gcloud.search
|
389
361
|
# index = search.index "books"
|
362
|
+
# index.delete
|
390
363
|
#
|
391
|
-
#
|
392
|
-
# option:
|
393
|
-
#
|
364
|
+
# @example Deleting an index containing documents with the `force` option:
|
394
365
|
# require "gcloud"
|
395
366
|
#
|
396
367
|
# gcloud = Gcloud.new
|
@@ -417,8 +388,8 @@ module Gcloud
|
|
417
388
|
end
|
418
389
|
|
419
390
|
##
|
420
|
-
# New Index from a raw data object.
|
421
|
-
def self.from_raw raw, conn
|
391
|
+
# @private New Index from a raw data object.
|
392
|
+
def self.from_raw raw, conn
|
422
393
|
new.tap do |f|
|
423
394
|
f.raw = raw
|
424
395
|
f.connection = conn
|
@@ -430,76 +401,76 @@ module Gcloud
|
|
430
401
|
|
431
402
|
##
|
432
403
|
# Runs a search against the documents in the index using the provided
|
433
|
-
# query.
|
434
|
-
#
|
435
|
-
#
|
436
|
-
#
|
437
|
-
#
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
441
|
-
#
|
442
|
-
#
|
443
|
-
#
|
444
|
-
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
452
|
-
#
|
453
|
-
#
|
454
|
-
#
|
455
|
-
#
|
456
|
-
#
|
457
|
-
#
|
458
|
-
#
|
459
|
-
#
|
460
|
-
#
|
461
|
-
#
|
462
|
-
#
|
463
|
-
#
|
464
|
-
#
|
465
|
-
#
|
466
|
-
#
|
467
|
-
#
|
468
|
-
#
|
469
|
-
#
|
470
|
-
#
|
471
|
-
#
|
404
|
+
# query.
|
405
|
+
#
|
406
|
+
# By default, Result objects are sorted by document rank. For more information
|
407
|
+
# see the [REST API documentation for Document.rank](https://cloud.google.com/search/reference/rest/v1/projects/indexes/documents#resource_representation.google.cloudsearch.v1.Document.rank).
|
408
|
+
#
|
409
|
+
# You can specify how to sort results with the `order` option. In the
|
410
|
+
# example below, the <code>-</code> character before `avg_review` means
|
411
|
+
# that results will be sorted in ascending order by `published` and then
|
412
|
+
# in descending order by `avg_review`. You can add computed fields with
|
413
|
+
# the `expressions` option, and limit the fields that are returned with
|
414
|
+
# the `fields` option.
|
415
|
+
#
|
416
|
+
# @see https://cloud.google.com/search/reference/rest/v1/projects/indexes/search
|
417
|
+
# The REST API documentation for indexes.search
|
418
|
+
#
|
419
|
+
# @param [String] query The query string in search query syntax. If the
|
420
|
+
# query is `nil` or empty, all documents are returned. For more
|
421
|
+
# information see [Query
|
422
|
+
# Strings](https://cloud.google.com/search/query).
|
423
|
+
# @param [Hash] expressions Customized expressions used in `order` or
|
424
|
+
# `fields`. The expression can contain fields in Document, the built-in
|
425
|
+
# fields ( `rank`, the document `rank`, and `score` if scoring is
|
426
|
+
# enabled) and fields defined in `expressions`. All field expressions
|
427
|
+
# expressed as a `Hash` with the keys as the `name` and the values as
|
428
|
+
# the `expression`. The expression value can be a combination of
|
429
|
+
# supported functions encoded in the string. Expressions involving
|
430
|
+
# number fields can use the arithmetical operators (+, -, *, /) and the
|
431
|
+
# built-in numeric functions (`max`, `min`, `pow`, `count`, `log`,
|
432
|
+
# `abs`). Expressions involving geopoint fields can use the `geopoint`
|
433
|
+
# and `distance` functions. Expressions for text and html fields can use
|
434
|
+
# the `snippet` function.
|
435
|
+
# @param [Integer] matched_count_accuracy Minimum accuracy requirement for
|
436
|
+
# {Result::List#matched_count}. If specified, `matched_count` will be
|
437
|
+
# accurate to at least that number. For example, when set to 100, any
|
438
|
+
# <code>matched_count <= 100</code> is accurate. This option may add
|
439
|
+
# considerable latency/expense. By default (when it is not specified or
|
440
|
+
# set to 0), the accuracy is the same as `max`.
|
441
|
+
# @param [Integer] offset Used to advance pagination to an arbitrary
|
442
|
+
# result, independent of the previous results. Offsets are an
|
443
|
+
# inefficient alternative to using `token`. (Both cannot be both set.)
|
444
|
+
# The default is 0.
|
445
|
+
# @param [String] order A comma-separated list of fields for sorting on
|
446
|
+
# the search result, including fields from Document, the built-in fields
|
447
|
+
# (`rank` and `score`), and fields defined in expressions. The default
|
448
|
+
# sorting order is ascending. To specify descending order for a field, a
|
449
|
+
# suffix <code>" desc"</code> should be appended to the field name. For
|
472
450
|
# example: <code>orderBy="foo desc,bar"</code>. The default value for
|
473
451
|
# text sort is the empty string, and the default value for numeric sort
|
474
452
|
# is 0. If not specified, the search results are automatically sorted by
|
475
|
-
# descending
|
476
|
-
#
|
477
|
-
#
|
478
|
-
#
|
479
|
-
#
|
480
|
-
#
|
481
|
-
#
|
482
|
-
#
|
483
|
-
#
|
484
|
-
#
|
485
|
-
#
|
486
|
-
#
|
487
|
-
#
|
488
|
-
#
|
489
|
-
#
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
#
|
496
|
-
#
|
497
|
-
# === Returns
|
498
|
-
#
|
499
|
-
# Array of Gcloud::Search::Result (See Gcloud::Search::Result::List)
|
500
|
-
#
|
501
|
-
# === Examples
|
502
|
-
#
|
453
|
+
# descending `rank`. Sorting by ascending `rank` is not allowed.
|
454
|
+
# @param [String, Array<String>] fields The fields to return in the
|
455
|
+
# {Search::Result} objects. These can be fields from {Document}, the
|
456
|
+
# built-in fields `rank` and `score`, and fields defined in expressions.
|
457
|
+
# The default is to return all fields.
|
458
|
+
# @param [String, Symbol] scorer The scoring function to invoke on a
|
459
|
+
# search result for this query. If scorer is not set, scoring is
|
460
|
+
# disabled and `score` is 0 for all documents in the search result. To
|
461
|
+
# enable document relevancy score based on term frequency, set `scorer`
|
462
|
+
# to `:generic`.
|
463
|
+
# @param [Integer] scorer_size Maximum number of top retrieved results to
|
464
|
+
# score. It is valid only when `scorer` is set. The default is 100.
|
465
|
+
# @param [String] token A previously-returned page token representing part
|
466
|
+
# of the larger set
|
467
|
+
# of results to view.
|
468
|
+
# @param [Integer] max Maximum number of results to return per page.
|
469
|
+
#
|
470
|
+
# @return [Array<Gcloud::Search::Result>] (See
|
471
|
+
# {Gcloud::Search::Result::List})
|
472
|
+
#
|
473
|
+
# @example
|
503
474
|
# require "gcloud"
|
504
475
|
#
|
505
476
|
# gcloud = Gcloud.new
|
@@ -511,9 +482,7 @@ module Gcloud
|
|
511
482
|
# puts result.doc_id
|
512
483
|
# end
|
513
484
|
#
|
514
|
-
#
|
515
|
-
# paginate through them: (See Gcloud::Search::Result::List)
|
516
|
-
#
|
485
|
+
# @example With pagination: (See {Gcloud::Search::Result::List})
|
517
486
|
# require "gcloud"
|
518
487
|
#
|
519
488
|
# gcloud = Gcloud.new
|
@@ -529,14 +498,7 @@ module Gcloud
|
|
529
498
|
# results = results.next
|
530
499
|
# end
|
531
500
|
#
|
532
|
-
#
|
533
|
-
# see the {REST API documentation for Document.rank}[https://cloud.google.com/search/reference/rest/v1/projects/indexes/documents#resource_representation.google.cloudsearch.v1.Document.rank].
|
534
|
-
#
|
535
|
-
# You can specify how to sort results with the +order+ option. In the example
|
536
|
-
# below, the <code>-</code> character before +avg_review+ means that results
|
537
|
-
# will be sorted in ascending order by +published+ and then in descending
|
538
|
-
# order by +avg_review+.
|
539
|
-
#
|
501
|
+
# @example With the `order` option:
|
540
502
|
# require "gcloud"
|
541
503
|
#
|
542
504
|
# gcloud = Gcloud.new
|
@@ -546,9 +508,7 @@ module Gcloud
|
|
546
508
|
# results = index.search "dark stormy", order: "published, avg_review desc"
|
547
509
|
# documents = index.search query # API call
|
548
510
|
#
|
549
|
-
#
|
550
|
-
# fields that are returned with the +fields+ option:
|
551
|
-
#
|
511
|
+
# @example With the `fields` option:
|
552
512
|
# require "gcloud"
|
553
513
|
#
|
554
514
|
# gcloud = Gcloud.new
|
@@ -559,8 +519,7 @@ module Gcloud
|
|
559
519
|
# expressions: { total_price: "(price + tax)" },
|
560
520
|
# fields: ["name", "total_price", "highlight"]
|
561
521
|
#
|
562
|
-
# Just as in documents,
|
563
|
-
#
|
522
|
+
# @example Just as in documents, data is accessible via {Fields} methods:
|
564
523
|
# require "gcloud"
|
565
524
|
#
|
566
525
|
# gcloud = Gcloud.new
|