1
|
|
|
// https:// lucene.apache.org/solr/guide/8_5/collection-management.html#collection-management |
2
|
|
|
// |
3
|
|
|
package solr |
4
|
|
|
|
5
|
|
|
import ( |
6
|
|
|
"context" |
7
|
|
|
"net/http" |
8
|
|
|
) |
9
|
|
|
|
10
|
|
|
type WT string |
11
|
|
|
|
12
|
|
|
const ( |
13
|
|
|
JSON WT = "json" |
14
|
|
|
XML WT = "xml" |
15
|
|
|
) |
16
|
|
|
|
17
|
|
|
type CollectionAction string |
18
|
|
|
|
19
|
|
|
const ( |
20
|
|
|
CreateAction CollectionAction = "CREATE" |
21
|
|
|
ReloadAction CollectionAction = "RELOAD" |
22
|
|
|
ModifyCollectionAction CollectionAction = "MODIFYCOLLECTION" |
23
|
|
|
ListAction CollectionAction = "LIST" |
24
|
|
|
RenameAction CollectionAction = "RENAME" |
25
|
|
|
DeleteAction CollectionAction = "DELETE" |
26
|
|
|
CollectionPropAction CollectionAction = "COLLECTIONPROP" |
27
|
|
|
MigrateAction CollectionAction = "MIGRATE" |
28
|
|
|
ReindexCollectionAction CollectionAction = "REINDEXCOLLECTION" |
29
|
|
|
ColStatusAction CollectionAction = "COLSTATUS" |
30
|
|
|
BackupAction CollectionAction = "BACKUP" |
31
|
|
|
RestoreAction CollectionAction = "RESTORE" |
32
|
|
|
RebalanceLeadersAction CollectionAction = "REBALANCELEADERS" |
33
|
|
|
) |
34
|
|
|
|
35
|
|
|
type ReindexCollectionCmd string |
36
|
|
|
|
37
|
|
|
const ( |
38
|
|
|
Start ReindexCollectionCmd = "start" |
39
|
|
|
Abort ReindexCollectionCmd = "abort" |
40
|
|
|
Status ReindexCollectionCmd = "status" |
41
|
|
|
) |
42
|
|
|
|
43
|
|
|
type RawSizeSamplingPercent string |
44
|
|
|
|
45
|
|
|
const ( |
46
|
|
|
FieldsBySize RawSizeSamplingPercent = "fieldsBySize" |
47
|
|
|
TypesBySize RawSizeSamplingPercent = "typesBySize" |
48
|
|
|
Summary RawSizeSamplingPercent = "summary" |
49
|
|
|
Details RawSizeSamplingPercent = "details" |
50
|
|
|
StoredFields RawSizeSamplingPercent = "storedFields" |
51
|
|
|
TermsTerms RawSizeSamplingPercent = "terms_terms" |
52
|
|
|
TermsPostings RawSizeSamplingPercent = "terms_postings" |
53
|
|
|
TermsPayloads RawSizeSamplingPercent = "terms_payloads" |
54
|
|
|
TermVectors RawSizeSamplingPercent = "termVectors" |
55
|
|
|
DocValues RawSizeSamplingPercent = "docValues_*" |
56
|
|
|
Points RawSizeSamplingPercent = "norms" |
57
|
|
|
) |
58
|
|
|
|
59
|
|
|
type collectionBase struct { |
60
|
|
|
Action CollectionAction `url:"action,omitempty"` |
61
|
|
|
WT WT `url:"wt,omitempty"` |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
type CollectionCreate struct { |
65
|
|
|
collectionBase |
66
|
|
|
// The name of the collection to be created. This parameter is required. |
67
|
|
|
Name string `url:"name,omitempty"` |
68
|
|
|
|
69
|
|
|
// The router name that will be used. The router defines how |
70
|
|
|
// documents will be distributed among the shards. Possible |
71
|
|
|
// values are implicit or compositeId, which is the default. |
72
|
|
|
// |
73
|
|
|
// The implicit router does not automatically route documents |
74
|
|
|
// to different shards. Whichever shard you indicate on the |
75
|
|
|
// indexing request (or within each document) will be used as |
76
|
|
|
// the destination for those documents. |
77
|
|
|
// |
78
|
|
|
// The compositeId router hashes the value in the uniqueKey field |
79
|
|
|
// and looks up that hash in the collection’s clusterstate to |
80
|
|
|
// determine which shard will receive the document, with the |
81
|
|
|
// additional ability to manually direct the routing. |
82
|
|
|
// |
83
|
|
|
// When using the implicit router, the shards parameter is required. |
84
|
|
|
// When using the compositeId router, the numShards parameter is required. |
85
|
|
|
// |
86
|
|
|
// For more information, see also the section Document Routing. |
87
|
|
|
RouterName string `url:"router.name,omitempty"` |
88
|
|
|
|
89
|
|
|
// The number of shards to be created as part of the collection. |
90
|
|
|
// This is a required parameter when the router.name is compositeId. |
91
|
|
|
NumShards int `url:"numShards,omitempty"` |
92
|
|
|
|
93
|
|
|
// A comma separated list of shard names, e.g., shard-x,shard-y,shard-z. |
94
|
|
|
// This is a required parameter when the router.name is implicit. |
95
|
|
|
Shards int `url:"shards,omitempty"` |
96
|
|
|
|
97
|
|
|
// The number of replicas to be created for each shard. The default is 1. |
98
|
|
|
// |
99
|
|
|
// This will create a NRT type of replica. If you want another type of replica, |
100
|
|
|
// see the tlogReplicas and pullReplica parameters below. See the section Types |
101
|
|
|
// of Replicas for more information about replica types. |
102
|
|
|
ReplicationFactor int `url:"replicationFactor,omitempty"` |
103
|
|
|
|
104
|
|
|
// The number of NRT (Near-Real-Time) replicas to create for this collection. |
105
|
|
|
// This type of replica maintains a transaction log and updates its index locally. |
106
|
|
|
// If you want all of your replicas to be of this type, you can simply use |
107
|
|
|
// replicationFactor instead. |
108
|
|
|
NrtReplicas int `url:"nrtReplicas,omitempty"` |
109
|
|
|
|
110
|
|
|
// The number of TLOG replicas to create for this collection. |
111
|
|
|
// This type of replica maintains a transaction log but only updates |
112
|
|
|
// its index via replication from a leader. See the section Types of |
113
|
|
|
// Replicas for more information about replica types. |
114
|
|
|
TLogReplicas int `url:"tlogReplicas,omitempty"` |
115
|
|
|
|
116
|
|
|
// The number of PULL replicas to create for this collection. |
117
|
|
|
// This type of replica does not maintain a transaction log and only |
118
|
|
|
// updates its index via replication from a leader. This type is not |
119
|
|
|
// eligible to become a leader and should not be the only type of replicas |
120
|
|
|
// in the collection. See the section Types of Replicas for more information |
121
|
|
|
// about replica types. |
122
|
|
|
PullReplicas int `url:"pullReplicas,omitempty"` |
123
|
|
|
|
124
|
|
|
// When creating collections, the shards and/or replicas are spread across all |
125
|
|
|
// available (i.e., live) nodes, and two replicas of the same shard will never |
126
|
|
|
// be on the same node. |
127
|
|
|
// |
128
|
|
|
// If a node is not live when the CREATE action is called, it will not get any |
129
|
|
|
// parts of the new collection, which could lead to too many replicas being created |
130
|
|
|
// on a single live node. Defining maxShardsPerNode sets a limit on the number of |
131
|
|
|
// replicas the CREATE action will spread to each node. |
132
|
|
|
// |
133
|
|
|
// If the entire collection can not be fit into the live nodes, no collection |
134
|
|
|
// will be created at all. The default maxShardsPerNode value is 1. A value of -1 means |
135
|
|
|
// unlimited. If a policy is also specified then the stricter of maxShardsPerNode and policy rules apply. |
136
|
|
|
MaxShardsPerNode int `url:"maxShardsPerNode,omitempty"` |
137
|
|
|
|
138
|
|
|
// Allows defining the nodes to spread the new collection across. The format is a |
139
|
|
|
// comma-separated list of node_names, such as localhost:8983_solr,localhost:8984_solr,localhost:8985_solr. |
140
|
|
|
// |
141
|
|
|
// If not provided, the CREATE operation will create shard-replicas spread across all live Solr nodes. |
142
|
|
|
// |
143
|
|
|
// Alternatively, use the special value of EMPTY to initially create no shard-replica |
144
|
|
|
// within the new collection and then later use the ADDREPLICA operation to add shard-replicas |
145
|
|
|
// when and where required. |
146
|
|
|
CreateNodeSet string `url:"createNodeSet,omitempty"` |
147
|
|
|
|
148
|
|
|
// Controls whether or not the shard-replicas created for this collection will be assigned to |
149
|
|
|
// the nodes specified by the createNodeSet in a sequential manner, or if the list of nodes |
150
|
|
|
// should be shuffled prior to creating individual replicas. |
151
|
|
|
// |
152
|
|
|
// A false value makes the results of a collection creation predictable and gives |
153
|
|
|
// more exact control over the location of the individual shard-replicas, but true can |
154
|
|
|
// be a better choice for ensuring replicas are distributed evenly across nodes. The default is true. |
155
|
|
|
// |
156
|
|
|
// This parameter is ignored if createNodeSet is not also specified. |
157
|
|
|
CreateNodeSetShuffle string `url:"createNodeSet.shuffle,omitempty"` |
158
|
|
|
|
159
|
|
|
// Defines the name of the configuration (which must already be stored in ZooKeeper) to use for |
160
|
|
|
// this collection. If not provided, Solr will use the configuration of _default configset |
161
|
|
|
// to create a new (and mutable) configset named <collectionName>.AUTOCREATED and will use it for |
162
|
|
|
// the new collection. When such a collection (that uses a copy of the _default configset) |
163
|
|
|
// is deleted, the autocreated configset is not deleted by default. |
164
|
|
|
CollectionConfigName string `url:"collection.configName,omitempty"` |
165
|
|
|
|
166
|
|
|
// If this parameter is specified, the router will look at the value of the field in an input |
167
|
|
|
// document to compute the hash and identify a shard instead of looking at the uniqueKey field. |
168
|
|
|
// If the field specified is null in the document, the document will be rejected. |
169
|
|
|
// |
170
|
|
|
// Please note that RealTime Get or retrieval by document ID would also require the |
171
|
|
|
// parameter _route_ (or shard.keys) to avoid a distributed search. |
172
|
|
|
RouterField string `url:"router.field,omitempty"` |
173
|
|
|
|
174
|
|
|
// Set core property name to value. See the section Defining core.properties for |
175
|
|
|
// details on supported properties and values. |
176
|
|
|
PropertyName string `url:"property.name,omitempty"` |
177
|
|
|
|
178
|
|
|
// When set to true, enables automatic addition of replicas when the number of active replicas |
179
|
|
|
// falls below the value set for replicationFactor. This may occur if a replica goes down, |
180
|
|
|
// for example. The default is false, which means new replicas will not be added. |
181
|
|
|
// |
182
|
|
|
// While this parameter is provided as part of Solr’s set of features to provide |
183
|
|
|
// autoscaling of clusters, it is available even when you have not implemented any |
184
|
|
|
// other part of autoscaling (such as a policy). See the section SolrCloud Autoscaling |
185
|
|
|
// Automatically Adding Replicas for more details about this option and how it can be used. |
186
|
|
|
AutoAddReplicas bool `url:"autoAddReplicas,omitempty"` |
187
|
|
|
|
188
|
|
|
// Replica placement rules. See the section Rule-based Replica Placement for details. |
189
|
|
|
Rule string `url:"rule,omitempty"` |
190
|
|
|
|
191
|
|
|
// Details of the snitch provider. See the section Rule-based Replica Placement for details. |
192
|
|
|
Snitch string `url:"snitch,omitempty"` |
193
|
|
|
|
194
|
|
|
// Name of the collection-level policy. See Defining Collection-Specific Policies for details. |
195
|
|
|
Policy string `url:"policy,omitempty"` |
196
|
|
|
|
197
|
|
|
// If true, the request will complete only when all affected replicas become active. The |
198
|
|
|
// default is false, which means that the API will return the status of the single action, |
199
|
|
|
// which may be before the new replica is online and active. |
200
|
|
|
WaitForFinalState string `url:"waitForFinalState,omitempty"` |
201
|
|
|
|
202
|
|
|
// The name of the collection with which all replicas of this collection must be co-located. |
203
|
|
|
// The collection must already exist and must have a single shard named shard1. See Colocating |
204
|
|
|
// collections for more details. |
205
|
|
|
WithCollection string `url:"withCollection,omitempty"` |
206
|
|
|
|
207
|
|
|
// Starting with version 8.1 when a collection is created additionally an alias can be created |
208
|
|
|
// that points to this collection. This parameter allows specifying the name of this alias, |
209
|
|
|
// effectively combining this operation with CREATEALIAS |
210
|
|
|
Alias string `url:"alias,omitempty"` |
211
|
|
|
|
212
|
|
|
// Request ID to track this action which will be processed asynchronously. |
213
|
|
|
Async bool `url:"async,omitempty"` |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
type CollectionReload struct { |
217
|
|
|
collectionBase |
218
|
|
|
|
219
|
|
|
// The name of the collection to reload. This parameter is required. |
220
|
|
|
Name string `url:"name,omitempty"` |
221
|
|
|
|
222
|
|
|
// Request ID to track this action which will be processed asynchronously. |
223
|
|
|
Async bool `url:"async,omitempty"` |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
type CollectionModifyCollection struct { |
227
|
|
|
collectionBase |
228
|
|
|
// The name of the collection to be modified. This parameter is required. |
229
|
|
|
Collection string `url:"collection,omitempty"` |
230
|
|
|
|
231
|
|
|
// Key-value pairs of attribute names and attribute values. |
232
|
|
|
// At least one attribute parameter is required. |
233
|
|
|
// |
234
|
|
|
// The attributes that can be modified are: |
235
|
|
|
// |
236
|
|
|
// Read-Only Mode |
237
|
|
|
// Setting the readOnly attribute to true puts the collection in read-only mode, in which any |
238
|
|
|
// index update requests are rejected. Other collection-level actions (e.g., adding / removing / moving replicas) |
239
|
|
|
// are still available in this mode. |
240
|
|
|
// |
241
|
|
|
// The transition from the (default) read-write to read-only mode consists of the following steps: |
242
|
|
|
// |
243
|
|
|
// the readOnly flag is changed in collection state, |
244
|
|
|
// any new update requests are rejected with 403 FORBIDDEN error code (ongoing long-running requests |
245
|
|
|
// are aborted, too), |
246
|
|
|
// a forced commit is performed to flush and commit any in-flight updates. |
247
|
|
|
MaxShardsPerNode int `url:"maxShardsPerNode,omitempty"` |
248
|
|
|
ReplicationFactor int `url:"replicationFactor,omitempty"` |
249
|
|
|
AutoAddReplicas int `url:"autoAddReplicas,omitempty"` |
250
|
|
|
ConfigName string `url:"collection.configName,omitempty"` |
251
|
|
|
Rule string `url:"rule,omitempty"` |
252
|
|
|
Snitch string `url:"snitch,omitempty"` |
253
|
|
|
Policy string `url:"policy,omitempty"` |
254
|
|
|
WithCollection string `url:"withCollection,omitempty"` |
255
|
|
|
ReadOnly bool `url:"readOnly,omitempty"` |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
type CollectionList struct { |
259
|
|
|
collectionBase |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
type CollectionRename struct { |
263
|
|
|
collectionBase |
264
|
|
|
|
265
|
|
|
// Name of the existing SolrCloud collection or an alias that refers to exactly one collection |
266
|
|
|
// and is not a Routed Alias. |
267
|
|
|
Name string `url:"name,omitempty"` |
268
|
|
|
|
269
|
|
|
// Target name of the collection. This will be the new alias that refers to the underlying |
270
|
|
|
// SolrCloud collection. The original name (or alias) of the collection will be replaced also |
271
|
|
|
// in the existing aliases so that they also refer to the new name. Target name must not be an |
272
|
|
|
// existing alias. |
273
|
|
|
Target string `url:"target,omitempty"` |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
type CollectionDelete struct { |
277
|
|
|
collectionBase |
278
|
|
|
|
279
|
|
|
// The name of the collection to delete. This parameter is required. |
280
|
|
|
Name string `url:"name,omitempty"` |
281
|
|
|
|
282
|
|
|
// Request ID to track this action which will be processed asynchronously. |
283
|
|
|
Async bool `url:"async,omitempty"` |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
type CollectionProp struct { |
287
|
|
|
collectionBase |
288
|
|
|
|
289
|
|
|
// The name of the collection for which the property would be set. |
290
|
|
|
Name string `url:"name,omitempty"` |
291
|
|
|
|
292
|
|
|
// The name of the property. |
293
|
|
|
PropertyName string `url:"propertyName,omitempty"` |
294
|
|
|
|
295
|
|
|
// The value of the property. When not provided, the property is deleted. |
296
|
|
|
PropertyValue string `url:"propertyValue,omitempty"` |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
type CollectionMigrate struct { |
300
|
|
|
collectionBase |
301
|
|
|
|
302
|
|
|
// The name of the source collection from which documents will be split. This parameter is required. |
303
|
|
|
Collection string `url:"collection,omitempty"` |
304
|
|
|
|
305
|
|
|
// The name of the target collection to which documents will be migrated. This parameter is required. |
306
|
|
|
TargetCollection string `url:"target.collection,omitempty"` |
307
|
|
|
|
308
|
|
|
// The routing key prefix. For example, if the uniqueKey of a document is "a!123", |
309
|
|
|
// then you would use split.key=a!. This parameter is required. |
310
|
|
|
SplitKey string `url:"split.key,omitempty"` |
311
|
|
|
|
312
|
|
|
// The timeout, in seconds, until which write requests made to the source collection for the |
313
|
|
|
// given split.key will be forwarded to the target shard. The default is 60 seconds. |
314
|
|
|
ForwardTimeout int `url:"forward.timeout,omitempty"` |
315
|
|
|
|
316
|
|
|
// Set core property name to value. See the section Defining core.properties for details |
317
|
|
|
// on supported properties and values. |
318
|
|
|
PropertyName string `url:"property.name,omitempty"` |
319
|
|
|
|
320
|
|
|
// Request ID to track this action which will be processed asynchronously. |
321
|
|
|
Async bool `url:"async,omitempty"` |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
type CollectionReindex struct { |
325
|
|
|
collectionBase |
326
|
|
|
|
327
|
|
|
// The name of the source collection from which documents will be split. This parameter is required. |
328
|
|
|
Name string `url:"name,omitempty"` |
329
|
|
|
|
330
|
|
|
// Optional command. Default command is start. Currently supported commands are: |
331
|
|
|
|
332
|
|
|
// start - default, starts processing if not already running, |
333
|
|
|
// abort - aborts an already running reindexing (or clears a left-over status after a crash), and deletes partial results, |
334
|
|
|
// status - returns detailed status of a running reindexing command. |
335
|
|
|
CMD ReindexCollectionCmd `url:"cmd,omitempty"` |
336
|
|
|
|
337
|
|
|
// Target collection name, optional. If not specified a unique name will be generated and after |
338
|
|
|
// all documents have been copied an alias will be created that points from the source collection |
339
|
|
|
// name to the unique sequentially-named collection, effectively "hiding" the original source |
340
|
|
|
// collection from regular update and search operations. |
341
|
|
|
Target string `url:"target,omitempty"` |
342
|
|
|
|
343
|
|
|
// Optional query to select documents for reindexing. Default value is *:*. |
344
|
|
|
Q string `url:"q,omitempty"` |
345
|
|
|
|
346
|
|
|
// Optional list of fields to reindex. Default value is *. |
347
|
|
|
FL string `url:"fl,omitempty"` |
348
|
|
|
|
349
|
|
|
// Documents are transferred in batches. Depending on the average size of the document large batch |
350
|
|
|
// sizes may cause memory issues. Default value is 100. |
351
|
|
|
Rows string `url:"rows,omitempty"` |
352
|
|
|
|
353
|
|
|
// Optional name of the configset for the target collection. Default is the same as the source collection. |
354
|
|
|
// There’s a number of optional parameters that determine the target collection layout. If they are |
355
|
|
|
// not specified in the request then their values are copied from the source collection. |
356
|
|
|
// The following parameters are currently supported (described in details in the CREATE collection section): |
357
|
|
|
// numShards, replicationFactor, nrtReplicas, tlogReplicas, pullReplicas, maxShardsPerNode, |
358
|
|
|
// autoAddReplicas, shards, policy, createNodeSet, createNodeSet.shuffle, router.*. |
359
|
|
|
ConfigName string `url:"configName,omitempty"` |
360
|
|
|
|
361
|
|
|
// Optional boolean. If true then after the processing is successfully finished the source |
362
|
|
|
// collection will be deleted. |
363
|
|
|
RemoveSource string `url:"removeSource,omitempty"` |
364
|
|
|
|
365
|
|
|
// Request ID to track this action which will be processed asynchronously. |
366
|
|
|
Async bool `url:"async,omitempty"` |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
type CollectionColStatus struct { |
370
|
|
|
collectionBase |
371
|
|
|
|
372
|
|
|
// Collection name (optional). If missing then it means all collections. |
373
|
|
|
Collection string `url:"collection,omitempty"` |
374
|
|
|
|
375
|
|
|
// Optional boolean. If true then additional information will be provided about SolrCore of shard leaders. |
376
|
|
|
CoreInfo string `url:"coreInfo,omitempty"` |
377
|
|
|
|
378
|
|
|
// Optional boolean. If true then segment information will be provided. |
379
|
|
|
Segments string `url:"segments,omitempty"` |
380
|
|
|
|
381
|
|
|
// Optional boolean. If true then detailed Lucene field information will be provided and their |
382
|
|
|
// corresponding Solr schema types. |
383
|
|
|
FieldInfo string `url:"fieldInfo,omitempty"` |
384
|
|
|
|
385
|
|
|
// Optional boolean. If true then additional information about the index files size and their |
386
|
|
|
// RAM usage will be provided |
387
|
|
|
SizeInfo string `url:"sizeInfo,omitempty"` |
388
|
|
|
|
389
|
|
|
// Optional boolean. If true then run the raw index data analysis tool (other boolean |
390
|
|
|
// options below imply this option if any of them are true). Command response will include |
391
|
|
|
// sections that show estimated breakdown of data size per field and per data type. |
392
|
|
|
RawSize string `url:"rawSize,omitempty"` |
393
|
|
|
|
394
|
|
|
// Optional boolean. If true then include also a more detailed breakdown of data size per field and per type. |
395
|
|
|
RawSizeSummary string `url:"rawSizeSummary,omitempty"` |
396
|
|
|
|
397
|
|
|
// Optional boolean. If true then provide exhaustive details that include statistical distribution |
398
|
|
|
// of items per field and per type as well as top 20 largest items per field. |
399
|
|
|
RawSizeDetails string `url:"rawSizeDetails,omitempty"` |
400
|
|
|
|
401
|
|
|
// Optional float. When the index is larger than a certain threshold (100k documents per shard) |
402
|
|
|
// only a part of data is actually retrieved and analyzed in order to reduce the IO load, and then |
403
|
|
|
// the final results are extrapolated. Values must be greater than 0 and less or equal to 100.0. |
404
|
|
|
// Default value is 5.0. Very small values (between 0.0 and 1.0) may introduce significant estimation |
405
|
|
|
// errors. Also, values that would result in less than 10 documents being sampled are rejected with an |
406
|
|
|
// exception. |
407
|
|
|
// |
408
|
|
|
// Response for this command always contains two sections: |
409
|
|
|
// |
410
|
|
|
// fieldsBySize is a map where field names are keys and values are estimated sizes of raw (uncompressed) data |
411
|
|
|
// that belongs to the field. The map is sorted by size so that it’s easy to see what field occupies most space. |
412
|
|
|
// typesBySize is a map where data types are the keys and values are estimates sizes of raw (uncompressed) |
413
|
|
|
// data of particular type. This map is also sorted by size. |
414
|
|
|
// Optional sections include: |
415
|
|
|
// |
416
|
|
|
// summary section containing a breakdown of data sizes for each field by data type. |
417
|
|
|
// details section containing detailed statistical summary of size distribution within each field, per data type. |
418
|
|
|
// This section also shows topN values by size from each field. |
419
|
|
|
// Data types shown in the response can be roughly divided into the following groups: |
420
|
|
|
// |
421
|
|
|
// storedFields - represents the raw uncompressed data in stored fields. For example, for UTF-8 strings this |
422
|
|
|
// represents the aggregated sum of the number of bytes in the strings' UTF-8 representation, for long numbers |
423
|
|
|
// this is 8 bytes per value, etc. |
424
|
|
|
// |
425
|
|
|
// terms_terms - represents the aggregated size of the term dictionary. The size of this data is affected by |
426
|
|
|
// the the number and length of unique terms, which in turn depends on the field size and the analysis chain. |
427
|
|
|
// |
428
|
|
|
// terms_postings - represents the aggregated size of all term position and offset information, if present. |
429
|
|
|
// This information may be absent if position-based searching, such as phrase queries, is not needed. |
430
|
|
|
// |
431
|
|
|
// terms_payloads - represents the aggregated size of all per-term payload data, if present. |
432
|
|
|
// norms - represents the aggregated size of field norm information. This information may be omitted if a field |
433
|
|
|
// has an omitNorms flag in the schema, which is common for fields that don’t need weighting or scoring by |
434
|
|
|
// field length. |
435
|
|
|
// |
436
|
|
|
// termVectors - represents the aggregated size of term vectors. |
437
|
|
|
// |
438
|
|
|
// docValues_* - represents aggregated size of doc values, by type (e.g., docValues_numeric, docValues_binary, etc). |
439
|
|
|
// |
440
|
|
|
// points - represents aggregated size of point values. |
441
|
|
|
RawSizeSamplingPercent RawSizeSamplingPercent `url:"rawSizeSamplingPercent,omitempty"` |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
type CollectionBackup struct { |
445
|
|
|
collectionBase |
446
|
|
|
|
447
|
|
|
// The collection where the indexes will be restored into. This parameter is required. |
448
|
|
|
Collection string `url:"collection,omitempty"` |
449
|
|
|
|
450
|
|
|
// The name of the existing backup that you want to restore. This parameter is required. |
451
|
|
|
Name string `url:"name,omitempty"` |
452
|
|
|
|
453
|
|
|
// The location on a shared drive for the RESTORE command to read from. Alternately it can be set |
454
|
|
|
// as a cluster property. |
455
|
|
|
Location string `url:"location,omitempty"` |
456
|
|
|
|
457
|
|
|
// Request ID to track this action which will be processed asynchronously. |
458
|
|
|
Async bool `url:"async,omitempty"` |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
type CollectionRestore struct { |
462
|
|
|
collectionBase |
463
|
|
|
|
464
|
|
|
// The collection where the indexes will be restored into. This parameter is required. |
465
|
|
|
Collection string `url:"collection,omitempty"` |
466
|
|
|
|
467
|
|
|
// The name of the existing backup that you want to restore. This parameter is required. |
468
|
|
|
Name string `url:"name,omitempty"` |
469
|
|
|
|
470
|
|
|
// The location on a shared drive for the RESTORE command to read from. Alternately it can be set |
471
|
|
|
// as a cluster property. |
472
|
|
|
Location string `url:"location,omitempty"` |
473
|
|
|
|
474
|
|
|
// Request ID to track this action which will be processed asynchronously. |
475
|
|
|
Async bool `url:"async,omitempty"` |
476
|
|
|
|
477
|
|
|
// The name of a repository to be used for the backup. If no repository is specified then the |
478
|
|
|
// local filesystem repository will be used automatically. |
479
|
|
|
Repository string `url:"repository,omitempty"` |
480
|
|
|
|
481
|
|
|
// Defines the name of the configurations to use for this collection. These must already be stored |
482
|
|
|
// in ZooKeeper. If not provided, Solr will default to the collection name as the configuration name. |
483
|
|
|
CollectionConfigName string `url:"collection.configName,omitempty"` |
484
|
|
|
|
485
|
|
|
// The number of replicas to be created for each shard. |
486
|
|
|
ReplicationFactor int `url:"replicationFactor,omitempty"` |
487
|
|
|
|
488
|
|
|
// The number of NRT (Near-Real-Time) replicas to create for this collection. This type of replica |
489
|
|
|
// maintains a transaction log and updates its index locally. This parameter behaves the same way |
490
|
|
|
// as setting replicationFactor parameter. |
491
|
|
|
NrtReplicas int `url:"nrtReplicas,omitempty"` |
492
|
|
|
|
493
|
|
|
// The number of TLOG replicas to create for this collection. This type of replica maintains a |
494
|
|
|
// transaction log but only updates its index via replication from a leader. See the section Types of |
495
|
|
|
// Replicas for more information about replica types. |
496
|
|
|
TLogReplicas int `url:"tlogReplicas,omitempty"` |
497
|
|
|
|
498
|
|
|
// The number of TLOG replicas to create for this collection. This type of replica maintains a |
499
|
|
|
// transaction log but only updates its index via replication from a leader. See the section Types |
500
|
|
|
// of Replicas for more information about replica types. |
501
|
|
|
PullReplicas int `url:"pullReplicas,omitempty"` |
502
|
|
|
|
503
|
|
|
// When creating collections, the shards and/or replicas are spread across all available (i.e., live) |
504
|
|
|
// nodes, and two replicas of the same shard will never be on the same node. |
505
|
|
|
// |
506
|
|
|
// If a node is not live when the CREATE operation is called, it will not get any parts of the new |
507
|
|
|
// collection, which could lead to too many replicas being created on a single live node. Defining |
508
|
|
|
// maxShardsPerNode sets a limit on the number of replicas CREATE will spread to each node. If the |
509
|
|
|
// entire collection can not be fit into the live nodes, no collection will be created at all. |
510
|
|
|
MaxShardsPerNode int `url:"maxShardsPerNode,omitempty"` |
511
|
|
|
|
512
|
|
|
// When set to true, enables auto addition of replicas on shared file systems. See the section |
513
|
|
|
// Automatically Add Replicas in SolrCloud for more details on settings and overrides. |
514
|
|
|
AutoAddReplicas string `url:"autoAddReplicas,omitempty"` |
515
|
|
|
|
516
|
|
|
// Set core property name to value. See the section Defining core.properties for details on |
517
|
|
|
// supported properties and values. |
518
|
|
|
PropertyName string `url:"property.name,omitempty"` |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
type CollectionRebalanceLeaders struct { |
522
|
|
|
collectionBase |
523
|
|
|
|
524
|
|
|
// The collection where the indexes will be restored into. This parameter is required. |
525
|
|
|
Collection string `url:"collection,omitempty"` |
526
|
|
|
|
527
|
|
|
// The maximum number of reassignments to have queue up at once. Values <=0 are use the default |
528
|
|
|
// value Integer.MAX_VALUE. |
529
|
|
|
// |
530
|
|
|
// When this number is reached, the process waits for one or more leaders to be successfully |
531
|
|
|
// assigned before adding more to the queue. |
532
|
|
|
MaxAtOnce string `url:"maxAtOnce,omitempty"` |
533
|
|
|
|
534
|
|
|
// Defaults to 60. This is the timeout value when waiting for leaders to be reassigned. If maxAtOnce |
535
|
|
|
// is less than the number of reassignments that will take place, this is the maximum interval that |
536
|
|
|
// any single wait for at least one reassignment. |
537
|
|
|
// |
538
|
|
|
// For example, if 10 reassignments are to take place and maxAtOnce is 1 and maxWaitSeconds is 60, |
539
|
|
|
// the upper bound on the time that the command may wait is 10 minutes. |
540
|
|
|
MaxWaitSeconds string `url:"maxWaitSeconds,omitempty"` |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
type CollectionAPI struct { |
544
|
|
|
client *Client |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
// CREATE: Create a Collection |
548
|
|
|
func (c *CollectionAPI) Create(ctx context.Context, collection CollectionCreate) (*Response, error) { |
549
|
|
|
collection.WT = JSON |
550
|
|
|
collection.Action = CreateAction |
551
|
|
|
|
552
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
553
|
|
|
if err != nil { |
554
|
|
|
return nil, err |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
response, err := c.client.Do(ctx, req) |
558
|
|
|
if err != nil { |
559
|
|
|
return nil, err |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
return response, err |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
// Reload: Reload a Collection |
566
|
|
|
func (c *CollectionAPI) Reload(ctx context.Context, collection CollectionReload) (*Response, error) { |
567
|
|
|
collection.WT = JSON |
568
|
|
|
collection.Action = ReloadAction |
569
|
|
|
|
570
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
571
|
|
|
if err != nil { |
572
|
|
|
return nil, err |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
response, err := c.client.Do(ctx, req) |
576
|
|
|
if err != nil { |
577
|
|
|
return nil, err |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
return response, err |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
// Modify: Modify Attributes of a Collection |
584
|
|
|
func (c *CollectionAPI) Modify(ctx context.Context, collection CollectionModifyCollection) (*Response, error) { |
585
|
|
|
collection.WT = JSON |
586
|
|
|
collection.Action = ModifyCollectionAction |
587
|
|
|
|
588
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
589
|
|
|
if err != nil { |
590
|
|
|
return nil, err |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
response, err := c.client.Do(ctx, req) |
594
|
|
|
if err != nil { |
595
|
|
|
return nil, err |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
return response, err |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
// List: List Collections |
602
|
|
|
func (c *CollectionAPI) List(ctx context.Context) (*Response, error) { |
603
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collectionBase{ |
604
|
|
|
Action: ListAction, |
605
|
|
|
WT: JSON, |
606
|
|
|
}, nil) |
607
|
|
|
if err != nil { |
608
|
|
|
return nil, err |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
response, err := c.client.Do(ctx, req) |
612
|
|
|
if err != nil { |
613
|
|
|
return nil, err |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
return response, err |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
// Rename: Rename a Collection |
620
|
|
|
func (c *CollectionAPI) Rename(ctx context.Context, collection CollectionRename) (*Response, error) { |
621
|
|
|
collection.WT = JSON |
622
|
|
|
collection.Action = RenameAction |
623
|
|
|
|
624
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
625
|
|
|
if err != nil { |
626
|
|
|
return nil, err |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
response, err := c.client.Do(ctx, req) |
630
|
|
|
if err != nil { |
631
|
|
|
return nil, err |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
return response, err |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
// Delete: Delete a Collection |
638
|
|
|
func (c *CollectionAPI) Delete(ctx context.Context, collection CollectionDelete) (*Response, error) { |
639
|
|
|
collection.WT = JSON |
640
|
|
|
collection.Action = DeleteAction |
641
|
|
|
|
642
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
643
|
|
|
if err != nil { |
644
|
|
|
return nil, err |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
response, err := c.client.Do(ctx, req) |
648
|
|
|
if err != nil { |
649
|
|
|
return nil, err |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
return response, err |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
// CollectionProp: Collection Properties |
656
|
|
|
// Add, edit or delete a collection property. |
657
|
|
|
func (c *CollectionAPI) CollectionProp(ctx context.Context, collection CollectionProp) (*Response, error) { |
658
|
|
|
collection.WT = JSON |
659
|
|
|
collection.Action = CollectionPropAction |
660
|
|
|
|
661
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
662
|
|
|
if err != nil { |
663
|
|
|
return nil, err |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
response, err := c.client.Do(ctx, req) |
667
|
|
|
if err != nil { |
668
|
|
|
return nil, err |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
return response, err |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
// Migrate: Migrate Documents to Another Collection |
675
|
|
|
func (c *CollectionAPI) Migrate(ctx context.Context, collection CollectionMigrate) (*Response, error) { |
676
|
|
|
collection.WT = JSON |
677
|
|
|
collection.Action = MigrateAction |
678
|
|
|
|
679
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
680
|
|
|
if err != nil { |
681
|
|
|
return nil, err |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
response, err := c.client.Do(ctx, req) |
685
|
|
|
if err != nil { |
686
|
|
|
return nil, err |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
return response, err |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
// ReindexCollection: Re-Index a Collection |
693
|
|
|
func (c *CollectionAPI) ReindexCollection(ctx context.Context, collection CollectionReindex) (*Response, error) { |
694
|
|
|
collection.WT = JSON |
695
|
|
|
collection.Action = ReindexCollectionAction |
696
|
|
|
|
697
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
698
|
|
|
if err != nil { |
699
|
|
|
return nil, err |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
response, err := c.client.Do(ctx, req) |
703
|
|
|
if err != nil { |
704
|
|
|
return nil, err |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
return response, err |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
// ColStatus: Detailed Status of a Collection’s Indexes |
711
|
|
|
// The COLSTATUS command provides a detailed description of the collection status, including low-level |
712
|
|
|
// index information about segments and field data. |
713
|
|
|
func (c *CollectionAPI) ColStatus(ctx context.Context, collection CollectionColStatus) (*Response, error) { |
714
|
|
|
collection.WT = JSON |
715
|
|
|
collection.Action = ColStatusAction |
716
|
|
|
|
717
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
718
|
|
|
if err != nil { |
719
|
|
|
return nil, err |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
response, err := c.client.Do(ctx, req) |
723
|
|
|
if err != nil { |
724
|
|
|
return nil, err |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
return response, err |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
// Backup: Backup Collection |
731
|
|
|
// Backs up Solr collections and associated configurations to a shared filesystem - for example a Network File System. |
732
|
|
|
func (c *CollectionAPI) Backup(ctx context.Context, collection CollectionBackup) (*Response, error) { |
733
|
|
|
collection.WT = JSON |
734
|
|
|
collection.Action = BackupAction |
735
|
|
|
|
736
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
737
|
|
|
if err != nil { |
738
|
|
|
return nil, err |
739
|
|
|
} |
740
|
|
|
|
741
|
|
|
response, err := c.client.Do(ctx, req) |
742
|
|
|
if err != nil { |
743
|
|
|
return nil, err |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
return response, err |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
// Restore: Restore Collection |
750
|
|
|
// Restores Solr indexes and associated configurations. |
751
|
|
|
func (c *CollectionAPI) Restore(ctx context.Context, collection CollectionRestore) (*Response, error) { |
752
|
|
|
collection.WT = JSON |
753
|
|
|
collection.Action = RestoreAction |
754
|
|
|
|
755
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
756
|
|
|
if err != nil { |
757
|
|
|
return nil, err |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
response, err := c.client.Do(ctx, req) |
761
|
|
|
if err != nil { |
762
|
|
|
return nil, err |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
return response, err |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
// RebalanceLeaders: Rebalance Leaders |
769
|
|
|
// Reassigns leaders in a collection according to the preferredLeader property across active nodes. |
770
|
|
|
func (c *CollectionAPI) RebalanceLeaders(ctx context.Context, collection CollectionRebalanceLeaders) (*Response, error) { |
771
|
|
|
collection.WT = JSON |
772
|
|
|
collection.Action = RebalanceLeadersAction |
773
|
|
|
|
774
|
|
|
req, err := c.client.NewRequest(ctx, http.MethodGet, "/solr/admin/collections", nil, collection, nil) |
775
|
|
|
if err != nil { |
776
|
|
|
return nil, err |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
response, err := c.client.Do(ctx, req) |
780
|
|
|
if err != nil { |
781
|
|
|
return nil, err |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
return response, err |
785
|
|
|
} |
786
|
|
|
|