Skip to content
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
19 changes: 18 additions & 1 deletion src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public interface IGeoIpProcessor : IProcessor

[DataMember(Name ="target_field")]
Field TargetField { get; set; }

/// <summary>
/// If <c>true</c>, only first found geoip data will be returned, even if field contains array.
/// Defaults to <c>true</c>
/// <para />
/// Available in Elasticsearch 7.6.0+
/// </summary>
[DataMember(Name = "first_only")]
bool? FirstOnly { get; set; }
}

/// <summary>
Expand All @@ -58,6 +67,10 @@ public class GeoIpProcessor : ProcessorBase, IGeoIpProcessor
public IEnumerable<string> Properties { get; set; }

public Field TargetField { get; set; }

/// <inheritdoc />
public bool? FirstOnly { get; set; }

protected override string Name => "geoip";
}

Expand All @@ -81,13 +94,14 @@ public class GeoIpProcessorDescriptor<T>
bool? IGeoIpProcessor.IgnoreMissing { get; set; }
IEnumerable<string> IGeoIpProcessor.Properties { get; set; }
Field IGeoIpProcessor.TargetField { get; set; }
bool? IGeoIpProcessor.FirstOnly { get; set; }

public GeoIpProcessorDescriptor<T> Field(Field field) => Assign(field, (a, v) => a.Field = v);

public GeoIpProcessorDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> objectPath) =>
Assign(objectPath, (a, v) => a.Field = v);

/// <inheritdoc />
/// <inheritdoc cref="IGeoIpProcessor.IgnoreMissing"/>
public GeoIpProcessorDescriptor<T> IgnoreMissing(bool? ignoreMissing = true) => Assign(ignoreMissing, (a, v) => a.IgnoreMissing = v);

public GeoIpProcessorDescriptor<T> TargetField(Field field) => Assign(field, (a, v) => a.TargetField = v);
Expand All @@ -100,5 +114,8 @@ public GeoIpProcessorDescriptor<T> TargetField<TValue>(Expression<Func<T, TValue
public GeoIpProcessorDescriptor<T> Properties(IEnumerable<string> properties) => Assign(properties, (a, v) => a.Properties = v);

public GeoIpProcessorDescriptor<T> Properties(params string[] properties) => Assign(properties, (a, v) => a.Properties = v);

/// <inheritdoc cref="IGeoIpProcessor.FirstOnly"/>
public GeoIpProcessorDescriptor<T> FirstOnly(bool? firstOnly = true) => Assign(firstOnly, (a, v) => a.FirstOnly = v);
}
}