Skip to content

Commit

Permalink
foreach put pipeline processors is no longer an array as per elastic/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Sep 27, 2016
1 parent ec88d25 commit f44c371
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/Nest/Ingest/Processors/ForeachProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public interface IForeachProcessor : IProcessor
[JsonProperty("field")]
Field Field { get; set; }

[JsonProperty("processors")]
IEnumerable<IProcessor> 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<IProcessor> Processors { get; set; }
public IProcessor Processor { get; set; }
}

public class ForeachProcessorDescriptor<T>
Expand All @@ -34,14 +34,14 @@ public class ForeachProcessorDescriptor<T>

Field IForeachProcessor.Field { get; set; }

IEnumerable<IProcessor> IForeachProcessor.Processors { get; set; }
IProcessor IForeachProcessor.Processor { get; set; }

public ForeachProcessorDescriptor<T> Field(Field field) => Assign(a => a.Field = field);

public ForeachProcessorDescriptor<T> Field(Expression<Func<T, object>> objectPath) =>
Assign(a => a.Field = objectPath);

public ForeachProcessorDescriptor<T> Processors(Func<ProcessorsDescriptor, IPromise<IList<IProcessor>>> selector) =>
Assign(a => a.Processors = selector?.Invoke(new ProcessorsDescriptor())?.Value);
public ForeachProcessorDescriptor<T> Processor(Func<ProcessorsDescriptor, IPromise<IList<IProcessor>>> selector) =>
Assign(a => a.Processor = selector?.Invoke(new ProcessorsDescriptor())?.Value?.FirstOrDefault());
}
}
18 changes: 6 additions & 12 deletions src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down Expand Up @@ -195,7 +192,7 @@ protected override LazyResponses ClientUsage() => Calls(
)
.Foreach<Project>(fe => fe
.Field(p => p.Tags)
.Processors(pps => pps
.Processor(pps => pps
.Uppercase<Tag>(uc => uc
.Field("_value.name")
)
Expand Down Expand Up @@ -274,12 +271,9 @@ protected override LazyResponses ClientUsage() => Calls(
new ForeachProcessor
{
Field = Infer.Field<Project>(p => p.Tags),
Processors = new IProcessor[]
Processor = new UppercaseProcessor
{
new UppercaseProcessor
{
Field = "_value.name"
}
Field = "_value.name"
}
},
new GrokProcessor
Expand Down

0 comments on commit f44c371

Please sign in to comment.