Skip to content

Commit fd69d56

Browse files
Add missing fields for IpProperty (#6088) (#6089)
Co-authored-by: Steve Gordon <[email protected]>
1 parent aba658b commit fd69d56

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/Nest/Mapping/Types/Specialized/Ip/IpAttribute.cs

+9
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ public string NullValue
2929
set => Self.NullValue = value;
3030
}
3131

32+
public bool IgnoreMalformed
33+
{
34+
get => Self.IgnoreMalformed.GetValueOrDefault();
35+
set => Self.IgnoreMalformed = value;
36+
}
37+
3238
double? IIpProperty.Boost { get; set; }
3339
bool? IIpProperty.Index { get; set; }
3440
string IIpProperty.NullValue { get; set; }
3541
private IIpProperty Self => this;
42+
bool? IIpProperty.IgnoreMalformed { get; set; }
43+
IInlineScript IIpProperty.Script { get; set; }
44+
OnScriptError? IIpProperty.OnScriptError { get; set; }
3645
}
3746
}

src/Nest/Mapping/Types/Specialized/Ip/IpProperty.cs

+49
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ public interface IIpProperty : IDocValuesProperty
2424

2525
[DataMember(Name ="null_value")]
2626
string NullValue { get; set; }
27+
28+
/// <summary>
29+
/// If <c>true</c>, malformed IP addresses are ignored. If <c>false</c> (default), malformed IP addresses throw an exception and reject the whole document.
30+
/// Note that this cannot be set if the script parameter is used.
31+
/// </summary>
32+
[DataMember(Name = "ignore_malformed")]
33+
bool? IgnoreMalformed { get; set; }
34+
35+
/// <summary>
36+
/// If this parameter is set, then the field will index values generated by this script, rather than reading the values directly from the source.
37+
/// If a value is set for this field on the input document, then the document will be rejected with an error.
38+
/// Scripts are in the same format as their runtime equivalent. Scripts can only be configured on long and double field types.
39+
/// </summary>
40+
[DataMember(Name = "script")]
41+
IInlineScript Script { get; set; }
42+
43+
/// <summary>
44+
/// Defines what to do if the script defined by the `script` parameter throws an error at indexing time.Accepts `reject` (default), which
45+
/// will cause the entire document to be rejected, and `ignore`, which will register the field in the document's ignored metadata field and
46+
/// continue indexing.This parameter can only be set if the `script` field is also set.
47+
/// </summary>
48+
[DataMember(Name = "on_script_error")]
49+
OnScriptError? OnScriptError { get; set; }
2750
}
2851

2952
/// <inheritdoc cref="IIpProperty"/>
@@ -35,6 +58,15 @@ public IpProperty() : base(FieldType.Ip) { }
3558
public double? Boost { get; set; }
3659
public bool? Index { get; set; }
3760
public string NullValue { get; set; }
61+
62+
/// <inheritdoc />
63+
public bool? IgnoreMalformed { get; set; }
64+
65+
/// <inheritdoc />
66+
public IInlineScript Script { get; set; }
67+
68+
/// <inheritdoc />
69+
public OnScriptError? OnScriptError { get; set; }
3870
}
3971

4072
/// <inheritdoc cref="IIpProperty"/>
@@ -48,12 +80,29 @@ public IpPropertyDescriptor() : base(FieldType.Ip) { }
4880
double? IIpProperty.Boost { get; set; }
4981
bool? IIpProperty.Index { get; set; }
5082
string IIpProperty.NullValue { get; set; }
83+
bool? IIpProperty.IgnoreMalformed { get; set; }
84+
IInlineScript IIpProperty.Script { get; set; }
85+
OnScriptError? IIpProperty.OnScriptError { get; set; }
5186

5287
public IpPropertyDescriptor<T> Index(bool? index = true) => Assign(index, (a, v) => a.Index = v);
5388

5489
[Obsolete("The server always treated this as a noop and has been removed in 7.10")]
5590
public IpPropertyDescriptor<T> Boost(double? boost) => Assign(boost, (a, v) => a.Boost = v);
5691

5792
public IpPropertyDescriptor<T> NullValue(string nullValue) => Assign(nullValue, (a, v) => a.NullValue = v);
93+
94+
public IpPropertyDescriptor<T> IgnoreMalformed(bool? ignoreMalformed = true) => Assign(ignoreMalformed, (a, v) => a.IgnoreMalformed = v);
95+
96+
/// <inheritdoc cref="IIpProperty.Script" />
97+
public IpPropertyDescriptor<T> Script(IInlineScript inlineScript) => Assign(inlineScript, (a, v) => a.Script = v);
98+
99+
/// <inheritdoc cref="IIpProperty.Script" />
100+
public IpPropertyDescriptor<T> Script(string source) => Assign(source, (a, v) => a.Script = new InlineScript(source));
101+
102+
/// <inheritdoc cref="IIpProperty.Script" />
103+
public IpPropertyDescriptor<T> Script(Func<InlineScriptDescriptor, IInlineScript> selector) => Assign(selector, (a, v) => a.Script = v?.Invoke(new InlineScriptDescriptor()));
104+
105+
/// <inheritdoc cref="IIpProperty.OnScriptError" />
106+
public IpPropertyDescriptor<T> OnScriptError(OnScriptError? onScriptError) => Assign(onScriptError, (a, v) => a.OnScriptError = v);
58107
}
59108
}

0 commit comments

Comments
 (0)