Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding to the documentation and tests for the _none pipeline #93057

Merged
merged 4 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/index-modules.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ Defaults to `*`, which matches all fields eligible for
Default <<ingest,ingest pipeline>> for the index. Index requests will fail
if the default pipeline is set and the pipeline does not exist. The default may be
overridden using the `pipeline` parameter. The special pipeline name `_none` indicates
no ingest pipeline should be run.
no default ingest pipeline will run.

[[index-final-pipeline]]
`index.final_pipeline`::
Final <<ingest,ingest pipeline>> for the index. Indexing requests
will fail if the final pipeline is set and the pipeline does not exist.
The final pipeline always runs after the request pipeline (if specified) and
the default pipeline (if it exists). The special pipeline name `_none`
indicates no ingest pipeline will run.
indicates no final ingest pipeline will run.
+
NOTE: You can't use a final pipeline to change the `_index` field. If the
pipeline attempts to change the `_index` field, the indexing request will fail.
Expand Down
5 changes: 4 additions & 1 deletion docs/reference/rest-api/common-parms.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,10 @@ end::payloads[]

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

tag::pages-processed[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,45 @@ teardown:
- is_false: _source.field1
- match: {_source.field2: value2}

---
"Test bulk request with _none request pipeline and default pipeline":

- do:
bulk:
pipeline: pipeline1
body:
- index:
_index: test_index
_id: test_id1
- f1: v1
- index:
_index: test_index
_id: test_id2
pipeline: _none
- f1: v2
- gte: { ingest_took: 0 }

- do:
cluster.state: {}
# Get master node id
- set: { master_node: master }

- do:
get:
index: test_index
id: test_id1

- match: {_source.field1: value1}
- is_false: _source.field2

- do:
get:
index: test_index
id: test_id2

- is_false: _source.field1
- is_false: _source.field2

---
"Update with pipeline":
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,90 @@ public void testPutPipelineWithVersionedUpdateIncrementsVersion() throws Excepti
assertThat(updatedConfig.getVersion(), equalTo(existingVersion + 1));
}

public void testResolvePipelinesWithNonePipeline() {
// _none request pipeline:
{
Metadata metadata = Metadata.builder().build();
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(false));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
}

// _none default pipeline:
{
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
.numberOfShards(1)
.numberOfReplicas(0);
Metadata metadata = Metadata.builder().put(builder).build();
IndexRequest indexRequest = new IndexRequest("idx");
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(false));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
}

// _none default pipeline with request pipeline:
{
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
.numberOfShards(1)
.numberOfReplicas(0);
Metadata metadata = Metadata.builder().put(builder).build();
IndexRequest indexRequest = new IndexRequest("idx").setPipeline("pipeline1");
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(true));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo("pipeline1"));
}

// _none request pipeline with default pipeline:
{
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
.settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default-pipeline"))
.numberOfShards(1)
.numberOfReplicas(0);
Metadata metadata = Metadata.builder().put(builder).build();
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(false));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
}

// _none request pipeline with final pipeline:
{
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
.settings(settings(Version.CURRENT).put(IndexSettings.FINAL_PIPELINE.getKey(), "final-pipeline"))
.numberOfShards(1)
.numberOfReplicas(0);
Metadata metadata = Metadata.builder().put(builder).build();
IndexRequest indexRequest = new IndexRequest("idx").setPipeline(IngestService.NOOP_PIPELINE_NAME);
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(true));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
assertThat(indexRequest.getFinalPipeline(), equalTo("final-pipeline"));
}

// _none final pipeline:
{
IndexMetadata.Builder builder = IndexMetadata.builder("idx")
.settings(settings(Version.CURRENT).put(IndexSettings.FINAL_PIPELINE.getKey(), IngestService.NOOP_PIPELINE_NAME))
.numberOfShards(1)
.numberOfReplicas(0);
Metadata metadata = Metadata.builder().put(builder).build();
IndexRequest indexRequest = new IndexRequest("idx").setPipeline("pipeline1");
boolean result = IngestService.resolvePipelines(indexRequest, indexRequest, metadata);
assertThat(result, is(true));
assertThat(indexRequest.isPipelineResolved(), is(true));
assertThat(indexRequest.getPipeline(), equalTo("pipeline1"));
assertThat(indexRequest.getFinalPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME));
}
}

private static Tuple<String, Object> randomMapEntry() {
return tuple(randomAlphaOfLength(5), randomObject());
}
Expand Down