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 1 commit
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
3 changes: 2 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,8 @@ 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. The special pipeline
name _none indicates no ingest pipeline will run, other than the final pipeline if it exists.
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,61 @@ 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 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"));
}
}

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