Skip to content

Commit ebb860d

Browse files
authored
Adding to the documentation and tests for the _none pipeline (#93057)
1 parent aaa215c commit ebb860d

File tree

4 files changed

+129
-3
lines changed

4 files changed

+129
-3
lines changed

docs/reference/index-modules.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ Defaults to `*`, which matches all fields eligible for
320320
Default <<ingest,ingest pipeline>> for the index. Index requests will fail
321321
if the default pipeline is set and the pipeline does not exist. The default may be
322322
overridden using the `pipeline` parameter. The special pipeline name `_none` indicates
323-
no ingest pipeline should be run.
323+
no default ingest pipeline will run.
324324

325325
[[index-final-pipeline]]
326326
`index.final_pipeline`::
327327
Final <<ingest,ingest pipeline>> for the index. Indexing requests
328328
will fail if the final pipeline is set and the pipeline does not exist.
329329
The final pipeline always runs after the request pipeline (if specified) and
330330
the default pipeline (if it exists). The special pipeline name `_none`
331-
indicates no ingest pipeline will run.
331+
indicates no final ingest pipeline will run.
332332
+
333333
NOTE: You can't use a final pipeline to change the `_index` field. If the
334334
pipeline attempts to change the `_index` field, the indexing request will fail.

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,10 @@ end::payloads[]
713713

714714
tag::pipeline[]
715715
`pipeline`::
716-
(Optional, string) ID of the pipeline to use to preprocess incoming documents.
716+
(Optional, string) ID of the pipeline to use to preprocess incoming documents. If the index has a
717+
default ingest pipeline specified, then setting the value to `_none` disables the default ingest
718+
pipeline for this request. If a final pipeline is configured it will always run, regardless of the
719+
value of this parameter.
717720
end::pipeline[]
718721

719722
tag::pages-processed[]

modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/70_bulk.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,45 @@ teardown:
145145
- is_false: _source.field1
146146
- match: {_source.field2: value2}
147147

148+
---
149+
"Test bulk request with _none request pipeline and default pipeline":
150+
151+
- do:
152+
bulk:
153+
pipeline: pipeline1
154+
body:
155+
- index:
156+
_index: test_index
157+
_id: test_id1
158+
- f1: v1
159+
- index:
160+
_index: test_index
161+
_id: test_id2
162+
pipeline: _none
163+
- f1: v2
164+
- gte: { ingest_took: 0 }
165+
166+
- do:
167+
cluster.state: {}
168+
# Get master node id
169+
- set: { master_node: master }
170+
171+
- do:
172+
get:
173+
index: test_index
174+
id: test_id1
175+
176+
- match: {_source.field1: value1}
177+
- is_false: _source.field2
178+
179+
- do:
180+
get:
181+
index: test_index
182+
id: test_id2
183+
184+
- is_false: _source.field1
185+
- is_false: _source.field2
186+
148187
---
149188
"Update with pipeline":
150189
- skip:

server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,90 @@ public void testPutPipelineWithVersionedUpdateIncrementsVersion() throws Excepti
21862186
assertThat(updatedConfig.getVersion(), equalTo(existingVersion + 1));
21872187
}
21882188

2189+
public void testResolvePipelinesWithNonePipeline() {
2190+
// _none request pipeline:
2191+
{
2192+
Metadata metadata = Metadata.builder().build();
2193+
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
2194+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2195+
assertThat(result, is(false));
2196+
assertThat(indexRequest.isPipelineResolved(), is(true));
2197+
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
2198+
}
2199+
2200+
// _none default pipeline:
2201+
{
2202+
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
2203+
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
2204+
.numberOfShards(1)
2205+
.numberOfReplicas(0);
2206+
Metadata metadata = Metadata.builder().put(builder).build();
2207+
IndexRequest indexRequest = new IndexRequest("idx");
2208+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2209+
assertThat(result, is(false));
2210+
assertThat(indexRequest.isPipelineResolved(), is(true));
2211+
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
2212+
}
2213+
2214+
// _none default pipeline with request pipeline:
2215+
{
2216+
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
2217+
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
2218+
.numberOfShards(1)
2219+
.numberOfReplicas(0);
2220+
Metadata metadata = Metadata.builder().put(builder).build();
2221+
IndexRequest indexRequest = new IndexRequest("idx").setPipeline("pipeline1");
2222+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2223+
assertThat(result, is(true));
2224+
assertThat(indexRequest.isPipelineResolved(), is(true));
2225+
assertThat(indexRequest.getPipeline(), equalTo("pipeline1"));
2226+
}
2227+
2228+
// _none request pipeline with default pipeline:
2229+
{
2230+
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
2231+
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default-pipeline"))
2232+
.numberOfShards(1)
2233+
.numberOfReplicas(0);
2234+
Metadata metadata = Metadata.builder().put(builder).build();
2235+
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
2236+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2237+
assertThat(result, is(false));
2238+
assertThat(indexRequest.isPipelineResolved(), is(true));
2239+
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
2240+
}
2241+
2242+
// _none request pipeline with final pipeline:
2243+
{
2244+
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
2245+
.settings(settings(Version.CURRENT).put(IndexSettings.FINAL_PIPELINE.getKey(), "final-pipeline"))
2246+
.numberOfShards(1)
2247+
.numberOfReplicas(0);
2248+
Metadata metadata = Metadata.builder().put(builder).build();
2249+
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
2250+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2251+
assertThat(result, is(true));
2252+
assertThat(indexRequest.isPipelineResolved(), is(true));
2253+
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
2254+
assertThat(indexRequest.getFinalPipeline(), equalTo("final-pipeline"));
2255+
}
2256+
2257+
// _none final pipeline:
2258+
{
2259+
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
2260+
.settings(settings(Version.CURRENT).put(IndexSettings.FINAL_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
2261+
.numberOfShards(1)
2262+
.numberOfReplicas(0);
2263+
Metadata metadata = Metadata.builder().put(builder).build();
2264+
IndexRequest indexRequest = new IndexRequest("idx").setPipeline("pipeline1");
2265+
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
2266+
assertThat(result, is(true));
2267+
assertThat(indexRequest.isPipelineResolved(), is(true));
2268+
assertThat(indexRequest.getPipeline(), equalTo("pipeline1"));
2269+
assertThat(indexRequest.getFinalPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
2270+
}
2271+
}
2272+
21892273
private static Tuple<String, Object> randomMapEntry() {
21902274
return tuple(randomAlphaOfLength(5), randomObject());
21912275
}

0 commit comments

Comments
 (0)