Skip to content

Commit 9358184

Browse files
russcamgithub-actions[bot]
authored andcommitted
Add first_only to geoip processor (#4410)
Relates: #4341, elastic/elasticsearch#49573
1 parent 9a08447 commit 9358184

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Nest/Ingest/Processors/Plugins/GeoIpProcessor.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public interface IGeoIpProcessor : IProcessor
3535

3636
[DataMember(Name ="target_field")]
3737
Field TargetField { get; set; }
38+
39+
/// <summary>
40+
/// If <c>true</c>, only first found geoip data will be returned, even if field contains array.
41+
/// Defaults to <c>true</c>
42+
/// <para />
43+
/// Available in Elasticsearch 7.6.0+
44+
/// </summary>
45+
[DataMember(Name = "first_only")]
46+
bool? FirstOnly { get; set; }
3847
}
3948

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

6069
public Field TargetField { get; set; }
70+
71+
/// <inheritdoc />
72+
public bool? FirstOnly { get; set; }
73+
6174
protected override string Name => "geoip";
6275
}
6376

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

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

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

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

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

102116
public GeoIpProcessorDescriptor<T> Properties(params string[] properties) => Assign(properties, (a, v) => a.Properties = v);
117+
118+
/// <inheritdoc cref="IGeoIpProcessor.FirstOnly"/>
119+
public GeoIpProcessorDescriptor<T> FirstOnly(bool? firstOnly = true) => Assign(firstOnly, (a, v) => a.FirstOnly = v);
103120
}
104121
}

0 commit comments

Comments
 (0)