You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Performs multiple indexing or delete operations in a single API call.
34
+
* Perform multiple `index`, `create`, `delete`, and `update` actions in a single request.
35
35
* This reduces overhead and can greatly increase indexing speed.
36
+
*
37
+
* If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:
38
+
*
39
+
* * To use the `create` action, you must have the `create_doc`, `create`, `index`, or `write` index privilege. Data streams support only the `create` action.
40
+
* * To use the `index` action, you must have the `create`, `index`, or `write` index privilege.
41
+
* * To use the `delete` action, you must have the `delete` or `write` index privilege.
42
+
* * To use the `update` action, you must have the `index` or `write` index privilege.
43
+
* * To automatically create a data stream or index with a bulk API request, you must have the `auto_configure`, `create_index`, or `manage` index privilege.
44
+
* * To make the result of a bulk operation visible to search using the `refresh` parameter, you must have the `maintenance` or `manage` index privilege.
45
+
*
46
+
* Automatic data stream creation requires a matching index template with data stream enabled.
47
+
*
48
+
* The actions are specified in the request body using a newline delimited JSON (NDJSON) structure:
49
+
*
50
+
* ```
51
+
* action_and_meta_data\n
52
+
* optional_source\n
53
+
* action_and_meta_data\n
54
+
* optional_source\n
55
+
* ....
56
+
* action_and_meta_data\n
57
+
* optional_source\n
58
+
* ```
59
+
*
60
+
* The `index` and `create` actions expect a source on the next line and have the same semantics as the `op_type` parameter in the standard index API.
61
+
* A `create` action fails if a document with the same ID already exists in the target
62
+
* An `index` action adds or replaces a document as necessary.
63
+
*
64
+
* NOTE: Data streams support only the `create` action.
65
+
* To update or delete a document in a data stream, you must target the backing index containing the document.
66
+
*
67
+
* An `update` action expects that the partial doc, upsert, and script and its options are specified on the next line.
68
+
*
69
+
* A `delete` action does not expect a source on the next line and has the same semantics as the standard delete API.
70
+
*
71
+
* NOTE: The final line of data must end with a newline character (`\n`).
72
+
* Each newline character may be preceded by a carriage return (`\r`).
73
+
* When sending NDJSON data to the `_bulk` endpoint, use a `Content-Type` header of `application/json` or `application/x-ndjson`.
74
+
* Because this format uses literal newline characters (`\n`) as delimiters, make sure that the JSON actions and sources are not pretty printed.
75
+
*
76
+
* If you provide a target in the request path, it is used for any actions that don't explicitly specify an `_index` argument.
77
+
*
78
+
* A note on the format: the idea here is to make processing as fast as possible.
79
+
* As some of the actions are redirected to other shards on other nodes, only `action_meta_data` is parsed on the receiving node side.
80
+
*
81
+
* Client libraries using this protocol should try and strive to do something similar on the client side, and reduce buffering as much as possible.
82
+
*
83
+
* There is no "correct" number of actions to perform in a single bulk request.
84
+
* Experiment with different settings to find the optimal size for your particular workload.
85
+
* Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by default so clients must ensure that no request exceeds this size.
86
+
* It is not possible to index a single document that exceeds the size limit, so you must pre-process any such documents into smaller pieces before sending them to Elasticsearch.
87
+
* For instance, split documents into pages or chapters before indexing them, or store raw binary data in a system outside Elasticsearch and replace the raw data with a link to the external system in the documents that you send to Elasticsearch.
88
+
*
89
+
* **Client suppport for bulk requests**
90
+
*
91
+
* Some of the officially supported clients provide helpers to assist with bulk requests and reindexing:
92
+
*
93
+
* * Go: Check out `esutil.BulkIndexer`
94
+
* * Perl: Check out `Search::Elasticsearch::Client::5_0::Bulk` and `Search::Elasticsearch::Client::5_0::Scroll`
95
+
* * Python: Check out `elasticsearch.helpers.*`
96
+
* * JavaScript: Check out `client.helpers.*`
97
+
* * .NET: Check out `BulkAllObservable`
98
+
* * PHP: Check out bulk indexing.
99
+
*
100
+
* **Submitting bulk requests with cURL**
101
+
*
102
+
* If you're providing text file input to `curl`, you must use the `--data-binary` flag instead of plain `-d`.
103
+
* The latter doesn't preserve newlines. For example:
* Each `index` and `delete` action within a bulk API call may include the `if_seq_no` and `if_primary_term` parameters in their respective action and meta data lines.
116
+
* The `if_seq_no` and `if_primary_term` parameters control how operations are run, based on the last modification to existing documents. See Optimistic concurrency control for more details.
117
+
*
118
+
* **Versioning**
119
+
*
120
+
* Each bulk item can include the version value using the `version` field.
121
+
* It automatically follows the behavior of the index or delete operation based on the `_version` mapping.
122
+
* It also support the `version_type`.
123
+
*
124
+
* **Routing**
125
+
*
126
+
* Each bulk item can include the routing value using the `routing` field.
127
+
* It automatically follows the behavior of the index or delete operation based on the `_routing` mapping.
128
+
*
129
+
* NOTE: Data streams do not support custom routing unless they were created with the `allow_custom_routing` setting enabled in the template.
130
+
*
131
+
* **Wait for active shards**
132
+
*
133
+
* When making bulk calls, you can set the `wait_for_active_shards` parameter to require a minimum number of shard copies to be active before starting to process the bulk request.
134
+
*
135
+
* **Refresh**
136
+
*
137
+
* Control when the changes made by this request are visible to search.
138
+
*
139
+
* NOTE: Only the shards that receive the bulk request will be affected by refresh.
140
+
* Imagine a `_bulk?refresh=wait_for` request with three documents in it that happen to be routed to different shards in an index with five shards.
141
+
* The request will only wait for those three shards to refresh.
142
+
* The other two shards that make up the index do not participate in the `_bulk` request at all.
* Name of the data stream, index, or index alias to perform bulk actions on.
163
+
* The name of the data stream, index, or index alias to perform bulk actions on.
57
164
*/
58
165
index?: IndexName
59
166
}
60
167
query_parameters: {
61
168
/**
62
-
* If `true`, the response will include the ingest pipelines that were executed for each index or create.
169
+
* If `true`, the response will include the ingest pipelines that were run for each index or create.
63
170
* @server_default false
64
171
*/
65
172
list_executed_pipelines?: boolean
66
173
/**
67
-
* ID of the pipeline to use to preprocess incoming documents.
68
-
* If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.
69
-
* If a final pipeline is configured it will always run, regardless of the value of this parameter.
174
+
* The pipeline identifier to use to preprocess incoming documents.
175
+
* If the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request.
176
+
* If a final pipeline is configured, it will always run regardless of the value of this parameter.
70
177
*/
71
178
pipeline?: string
72
179
/**
73
-
* If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.
180
+
* If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search.
181
+
* If `wait_for`, wait for a refresh to make this operation visible to search.
182
+
* If `false`, do nothing with refreshes.
74
183
* Valid values: `true`, `false`, `wait_for`.
75
184
* @server_default false
76
185
*/
77
186
refresh?: Refresh
78
187
/**
79
-
* Custom value used to route operations to a specific shard.
188
+
* A custom value that is used to route operations to a specific shard.
80
189
*/
81
190
routing?: Routing
82
191
/**
83
-
* `true` or `false` to return the `_source` field or not, or a list of fields to return.
192
+
* Indicates whether to return the `_source` field (`true` or `false`) or contains a list of fields to return.
84
193
*/
85
194
_source?: SourceConfigParam
86
195
/**
87
196
* A comma-separated list of source fields to exclude from the response.
197
+
* You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
198
+
* If the `_source` parameter is `false`, this parameter is ignored.
88
199
*/
89
200
_source_excludes?: Fields
90
201
/**
91
202
* A comma-separated list of source fields to include in the response.
203
+
* If this parameter is specified, only these source fields are returned.
204
+
* You can exclude fields from this subset using the `_source_excludes` query parameter.
205
+
* If the `_source` parameter is `false`, this parameter is ignored.
92
206
*/
93
207
_source_includes?: Fields
94
208
/**
95
-
* Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
209
+
* The period each action waits for the following operations: automatic index creation, dynamic mapping updates, and waiting for active shards.
210
+
* The default is `1m` (one minute), which guarantees Elasticsearch waits for at least the timeout before failing.
211
+
* The actual wait time could be longer, particularly when multiple waits occur.
96
212
* @server_default 1m
97
213
*/
98
214
timeout?: Duration
99
215
/**
100
216
* The number of shard copies that must be active before proceeding with the operation.
101
-
* Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
217
+
* Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
218
+
* The default is `1`, which waits for each primary shard to be active.
102
219
* @server_default 1
103
220
*/
104
221
wait_for_active_shards?: WaitForActiveShards
105
222
/**
106
-
* If `true`, the request’s actions must target an index alias.
223
+
* If `true`, the request's actions must target an index alias.
107
224
* @server_default false
108
225
*/
109
226
require_alias?: boolean
110
227
/**
111
-
* If `true`, the request's actions must target a data stream (existing or to-be-created).
228
+
* If `true`, the request's actions must target a data stream (existing or to be created).
When you run `POST _bulk` and use the `update` action, you can use `retry_on_conflict` as a field in the action itself (not in the extra payload line) to specify how many times an update should be retried in the case of a version conflict.
Run `POST /_bulk` to perform a bulk request that consists of index and create actions with the `dynamic_templates` parameter.
5
+
The bulk request creates two new fields `work_location` and `home_location` with type `geo_point` according to the `dynamic_templates` parameter.
6
+
However, the `raw_location` field is created using default dynamic mapping rules, as a text field in that case since it is supplied as a string in the JSON document.
0 commit comments