From 7162d92857545ae0d97598e22d807195cc55b0ab Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Fri, 21 Feb 2020 16:24:29 +1000 Subject: [PATCH] Add first_only to geoip processor Relates: #4341, elastic/elasticsearch#49573 --- .../Processors/Plugins/GeoIpProcessor.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs b/src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs index 8291ee217af..80be01f295c 100644 --- a/src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs +++ b/src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs @@ -35,6 +35,15 @@ public interface IGeoIpProcessor : IProcessor [DataMember(Name ="target_field")] Field TargetField { get; set; } + + /// + /// If true, only first found geoip data will be returned, even if field contains array. + /// Defaults to true + /// + /// Available in Elasticsearch 7.6.0+ + /// + [DataMember(Name = "first_only")] + bool? FirstOnly { get; set; } } /// @@ -58,6 +67,10 @@ public class GeoIpProcessor : ProcessorBase, IGeoIpProcessor public IEnumerable Properties { get; set; } public Field TargetField { get; set; } + + /// + public bool? FirstOnly { get; set; } + protected override string Name => "geoip"; } @@ -81,13 +94,14 @@ public class GeoIpProcessorDescriptor bool? IGeoIpProcessor.IgnoreMissing { get; set; } IEnumerable IGeoIpProcessor.Properties { get; set; } Field IGeoIpProcessor.TargetField { get; set; } + bool? IGeoIpProcessor.FirstOnly { get; set; } public GeoIpProcessorDescriptor Field(Field field) => Assign(field, (a, v) => a.Field = v); public GeoIpProcessorDescriptor Field(Expression> objectPath) => Assign(objectPath, (a, v) => a.Field = v); - /// + /// public GeoIpProcessorDescriptor IgnoreMissing(bool? ignoreMissing = true) => Assign(ignoreMissing, (a, v) => a.IgnoreMissing = v); public GeoIpProcessorDescriptor TargetField(Field field) => Assign(field, (a, v) => a.TargetField = v); @@ -100,5 +114,8 @@ public GeoIpProcessorDescriptor TargetField(Expression Properties(IEnumerable properties) => Assign(properties, (a, v) => a.Properties = v); public GeoIpProcessorDescriptor Properties(params string[] properties) => Assign(properties, (a, v) => a.Properties = v); + + /// + public GeoIpProcessorDescriptor FirstOnly(bool? firstOnly = true) => Assign(firstOnly, (a, v) => a.FirstOnly = v); } }