Skip to content

Commit 8bbd839

Browse files
russcamMpdreamz
authored andcommitted
Use ScriptProcessorDescriptor in the fluent API (#2422)
1 parent 90fab3c commit 8bbd839

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/Nest/Ingest/ProcessorsDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public ProcessorsDescriptor Rename<T>(Func<RenameProcessorDescriptor<T>, IRename
8484
/// <summary>
8585
/// Allows inline, stored, and file scripts to be executed within ingest pipelines.
8686
/// </summary>
87-
public ProcessorsDescriptor Script(Func<ScriptProcessor, IScriptProcessor> selector) =>
88-
Assign(a => a.AddIfNotNull(selector?.Invoke(new ScriptProcessor())));
87+
public ProcessorsDescriptor Script(Func<ScriptProcessorDescriptor, IScriptProcessor> selector) =>
88+
Assign(a => a.AddIfNotNull(selector?.Invoke(new ScriptProcessorDescriptor())));
8989

9090
public ProcessorsDescriptor Set<T>(Func<SetProcessorDescriptor<T>, ISetProcessor> selector) where T : class =>
9191
Assign(a => a.AddIfNotNull(selector?.Invoke(new SetProcessorDescriptor<T>())));

src/Tests/Ingest/PutPipeline/PutPipelineApiTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ protected override LazyResponses ClientUsage() => Calls(
163163
{
164164
field = "name"
165165
}
166+
},
167+
new
168+
{
169+
dot_expander = new
170+
{
171+
field = "field.withDots"
172+
}
173+
},
174+
new
175+
{
176+
script = new
177+
{
178+
inline = "ctx.numberOfCommits++"
179+
}
166180
}
167181
}
168182
};
@@ -239,6 +253,12 @@ protected override LazyResponses ClientUsage() => Calls(
239253
.Uppercase<Project>(u => u
240254
.Field(p => p.Name)
241255
)
256+
.DotExpander<Project>(de => de
257+
.Field("field.withDots")
258+
)
259+
.Script(s => s
260+
.Inline("ctx.numberOfCommits++")
261+
)
242262
);
243263

244264
protected override PutPipelineRequest Initializer => new PutPipelineRequest(_id)
@@ -327,6 +347,14 @@ protected override LazyResponses ClientUsage() => Calls(
327347
new UppercaseProcessor
328348
{
329349
Field = "name"
350+
},
351+
new DotExpanderProcessor
352+
{
353+
Field = "field.withDots"
354+
},
355+
new ScriptProcessor
356+
{
357+
Inline = "ctx.numberOfCommits++"
330358
}
331359
}
332360
};

0 commit comments

Comments
 (0)