diff --git a/src/Nest/Ingest/Processors/ForeachProcessor.cs b/src/Nest/Ingest/Processors/ForeachProcessor.cs index 9beb489794b..a33c6867e35 100644 --- a/src/Nest/Ingest/Processors/ForeachProcessor.cs +++ b/src/Nest/Ingest/Processors/ForeachProcessor.cs @@ -15,15 +15,15 @@ public interface IForeachProcessor : IProcessor [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("processors")] - IEnumerable Processors { get; set; } + [JsonProperty("processor")] + IProcessor Processor { get; set; } } public class ForeachProcessor : ProcessorBase, IForeachProcessor { protected override string Name => "foreach"; public Field Field { get; set; } - public IEnumerable Processors { get; set; } + public IProcessor Processor { get; set; } } public class ForeachProcessorDescriptor @@ -34,14 +34,14 @@ public class ForeachProcessorDescriptor Field IForeachProcessor.Field { get; set; } - IEnumerable IForeachProcessor.Processors { get; set; } + IProcessor IForeachProcessor.Processor { get; set; } public ForeachProcessorDescriptor Field(Field field) => Assign(a => a.Field = field); public ForeachProcessorDescriptor Field(Expression> objectPath) => Assign(a => a.Field = objectPath); - public ForeachProcessorDescriptor Processors(Func>> selector) => - Assign(a => a.Processors = selector?.Invoke(new ProcessorsDescriptor())?.Value); + public ForeachProcessorDescriptor Processor(Func>> selector) => + Assign(a => a.Processor = selector?.Invoke(new ProcessorsDescriptor())?.Value?.FirstOrDefault()); } } diff --git a/src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs b/src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs index 35edefc7e50..de51f359029 100644 --- a/src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs +++ b/src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs @@ -73,14 +73,11 @@ protected override LazyResponses ClientUsage() => Calls( @foreach = new { field = "tags", - processors = new object[] + processors = new { - new + uppercase = new { - uppercase = new - { - field = "_value.name" - } + field = "_value.name" } } } @@ -195,7 +192,7 @@ protected override LazyResponses ClientUsage() => Calls( ) .Foreach(fe => fe .Field(p => p.Tags) - .Processors(pps => pps + .Processor(pps => pps .Uppercase(uc => uc .Field("_value.name") ) @@ -274,12 +271,9 @@ protected override LazyResponses ClientUsage() => Calls( new ForeachProcessor { Field = Infer.Field(p => p.Tags), - Processors = new IProcessor[] + Processor = new UppercaseProcessor { - new UppercaseProcessor - { - Field = "_value.name" - } + Field = "_value.name" } }, new GrokProcessor