Skip to content

Commit 0792de8

Browse files
Add description to ingest processors (#4871) (#4883)
This commit adds description to ingest processors to allow users to explain the purpose of a specific processor instance. Co-authored-by: Russ Cam <[email protected]>
1 parent 2f09e39 commit 0792de8

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/Nest/Ingest/Processor.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System;
5+
using System;
66
using System.Collections.Generic;
77
using System.Runtime.Serialization;
88
using Elasticsearch.Net.Utf8Json;
@@ -18,6 +18,14 @@ public interface IProcessor
1818
[IgnoreDataMember]
1919
string Name { get; }
2020

21+
/// <summary>
22+
/// A description to explain the purpose of the specific processor instance.
23+
/// <para />
24+
/// Valid in Elasticsearch 7.9.0+
25+
/// </summary>
26+
[DataMember(Name = "description")]
27+
string Description { get; set; }
28+
2129
/// <summary>
2230
/// If a processor fails, call these processors instead. Read more about handling failures here:
2331
/// https://www.elastic.co/guide/en/elasticsearch/reference/current/handling-failure-in-pipelines.html
@@ -54,6 +62,9 @@ public abstract class ProcessorBase : IProcessor
5462
/// <inheritdoc cref="IProcessor.OnFailure"/>
5563
public IEnumerable<IProcessor> OnFailure { get; set; }
5664
protected abstract string Name { get; }
65+
/// <inheritdoc cref="IProcessor.Description"/>
66+
public string Description { get; set; }
67+
5768
string IProcessor.Name => Name;
5869
}
5970

@@ -65,11 +76,15 @@ public abstract class ProcessorDescriptorBase<TProcessorDescriptor, TProcessorIn
6576
{
6677
protected abstract string Name { get; }
6778
string IProcessor.Name => Name;
79+
string IProcessor.Description { get; set; }
6880
IEnumerable<IProcessor> IProcessor.OnFailure { get; set; }
6981
string IProcessor.If { get; set; }
7082
string IProcessor.Tag { get; set; }
7183
bool? IProcessor.IgnoreFailure { get; set; }
7284

85+
/// <inheritdoc cref="IProcessor.Description"/>
86+
public TProcessorDescriptor Description(string description) => Assign(description, (a, v) => a.Description = v);
87+
7388
/// <inheritdoc cref="IProcessor.OnFailure"/>
7489
public TProcessorDescriptor OnFailure(IEnumerable<IProcessor> processors) => Assign(processors.ToListOrNullIfEmpty(), (a, v) => a.OnFailure = v);
7590

tests/Tests/Ingest/ProcessorAssertions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class Append : ProcessorAssertion
7575
public override string Key => "append";
7676
}
7777

78-
[SkipVersion("<7.8.0", "Empty Value bug in versions less than Elasticsearch 7.8.0")]
78+
[SkipVersion("<7.9.0", "Description added in 7.9.0")]
7979
public class Csv : ProcessorAssertion
8080
{
8181
public override Func<ProcessorsDescriptor, IPromise<IList<IProcessor>>> Fluent => d => d
@@ -84,22 +84,25 @@ public class Csv : ProcessorAssertion
8484
.TargetFields(new[] { "targetField1", "targetField2" })
8585
.EmptyValue("empty")
8686
.Trim()
87+
.Description("parses CSV")
8788
);
8889

8990
public override IProcessor Initializer => new CsvProcessor
9091
{
9192
Field = "name",
9293
TargetFields = new[] { "targetField1", "targetField2" },
9394
EmptyValue = "empty",
94-
Trim = true
95+
Trim = true,
96+
Description = "parses CSV"
9597
};
9698

9799
public override object Json => new
98100
{
99101
field = "name",
100102
target_fields = new[] { "targetField1", "targetField2" },
101103
empty_value = "empty",
102-
trim = true
104+
trim = true,
105+
description = "parses CSV"
103106
};
104107

105108
public override string Key => "csv";

0 commit comments

Comments
 (0)