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

[Backport 7.9] Add ignore_empty_value to set processor #4932

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Changes from all commits
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
17 changes: 17 additions & 0 deletions src/Nest/Ingest/Processors/SetProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public interface ISetProcessor : IProcessor
/// </summary>
[DataMember(Name = "override")]
bool? Override { get; set; }

/// <summary>
/// If <c>true</c> and value is a template snippet that evaluates to null or the
/// empty string, the processor quietly exits without modifying the document.
/// Defaults to <c>false</c>.
/// <para />
/// Valid in Elasticsearch 7.9.0+
/// </summary>
[DataMember(Name = "ignore_empty_value")]
bool? IgnoreEmptyValue { get; set; }
}

/// <inheritdoc cref="ISetProcessor" />
Expand All @@ -47,6 +57,8 @@ public class SetProcessor : ProcessorBase, ISetProcessor
public object Value { get; set; }
/// <inheritdoc />
public bool? Override { get; set; }
/// <inheritdoc />
public bool? IgnoreEmptyValue { get; set; }
protected override string Name => "set";
}

Expand All @@ -58,6 +70,7 @@ public class SetProcessorDescriptor<T> : ProcessorDescriptorBase<SetProcessorDes
Field ISetProcessor.Field { get; set; }
object ISetProcessor.Value { get; set; }
bool? ISetProcessor.Override { get; set; }
bool? ISetProcessor.IgnoreEmptyValue { get; set; }

/// <inheritdoc cref="ISetProcessor.Field"/>
public SetProcessorDescriptor<T> Field(Field field) => Assign(field, (a, v) => a.Field = v);
Expand All @@ -71,5 +84,9 @@ public SetProcessorDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> objec

/// <inheritdoc cref="ISetProcessor.Override"/>
public SetProcessorDescriptor<T> Override(bool? @override = true) => Assign(@override, (a, v) => a.Override = v);

/// <inheritdoc cref="ISetProcessor.IgnoreEmptyValue"/>
public SetProcessorDescriptor<T> IgnoreEmptyValue(bool? ignoreEmptyValue = true) =>
Assign(ignoreEmptyValue, (a, v) => a.IgnoreEmptyValue = v);
}
}