Skip to content

Commit

Permalink
Add ignore_missing to the remove processor (#3441)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored and russcam committed Oct 17, 2018
1 parent ae5ae5b commit ee4096e
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/Nest/Ingest/Processors/RemoveProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Nest
{
Expand All @@ -14,25 +10,42 @@ public interface IRemoveProcessor : IProcessor
{
[JsonProperty("field")]
Field Field { get; set; }

/// <summary>
/// If <c>true</c> and <see cref="Field"/> does not exist or is null,
/// the processor quietly exits without modifying the document. Default is <c>false</c>
/// </summary>
[JsonProperty("ignore_missing")]
bool? IgnoreMissing { get; set; }
}

/// <inheritdoc cref="IRemoveProcessor" />
public class RemoveProcessor : ProcessorBase, IRemoveProcessor
{
protected override string Name => "remove";
/// <inheritdoc cref="IRemoveProcessor.Field" />
public Field Field { get; set; }
/// <inheritdoc cref="IRemoveProcessor.IgnoreMissing" />
public bool? IgnoreMissing { get; set; }
}

/// <inheritdoc cref="IRemoveProcessor" />
public class RemoveProcessorDescriptor<T>
: ProcessorDescriptorBase<RemoveProcessorDescriptor<T>, IRemoveProcessor>, IRemoveProcessor
where T : class
{
protected override string Name => "remove";

Field IRemoveProcessor.Field { get; set; }
bool? IRemoveProcessor.IgnoreMissing { get; set; }

/// <inheritdoc cref="IRemoveProcessor.Field" />
public RemoveProcessorDescriptor<T> Field(Field field) => Assign(a => a.Field = field);

public RemoveProcessorDescriptor<T> Field(Expression<Func<T, object>> objectPath) =>
Assign(a => a.Field = objectPath);
/// <inheritdoc cref="IRemoveProcessor.Field" />
public RemoveProcessorDescriptor<T> Field(Expression<Func<T, object>> objectPath) => Assign(a => a.Field = objectPath);

/// <inheritdoc cref="IRemoveProcessor.IgnoreMissing" />
public RemoveProcessorDescriptor<T> IgnoreMissing(bool? ignoreMissing = true) => Assign(a => a.IgnoreMissing = ignoreMissing);
}
}

0 comments on commit ee4096e

Please sign in to comment.