@@ -37,6 +37,22 @@ public interface INumberProperty : IDocValuesProperty
37
37
38
38
[ DataMember ( Name = "scaling_factor" ) ]
39
39
double ? ScalingFactor { get ; set ; }
40
+
41
+ /// <summary>
42
+ /// If this parameter is set, then the field will index values generated by this script, rather than reading the values directly from the source.
43
+ /// If a value is set for this field on the input document, then the document will be rejected with an error.
44
+ /// Scripts are in the same format as their runtime equivalent. Scripts can only be configured on long and double field types.
45
+ /// </summary>
46
+ [ DataMember ( Name = "script" ) ]
47
+ IInlineScript Script { get ; set ; }
48
+
49
+ /// <summary>
50
+ /// Defines what to do if the script defined by the `script` parameter throws an error at indexing time.Accepts `reject` (default), which
51
+ /// will cause the entire document to be rejected, and `ignore`, which will register the field in the document's ignored metadata field and
52
+ /// continue indexing.This parameter can only be set if the `script` field is also set.
53
+ /// </summary>
54
+ [ DataMember ( Name = "on_script_error" ) ]
55
+ OnScriptError ? OnScriptError { get ; set ; }
40
56
}
41
57
42
58
[ DebuggerDisplay ( "{DebugDisplay}" ) ]
@@ -50,10 +66,15 @@ public NumberProperty(NumberType type) : base(type.ToFieldType()) { }
50
66
public bool ? Coerce { get ; set ; }
51
67
public INumericFielddata Fielddata { get ; set ; }
52
68
public bool ? IgnoreMalformed { get ; set ; }
53
-
54
69
public bool ? Index { get ; set ; }
55
70
public double ? NullValue { get ; set ; }
56
71
public double ? ScalingFactor { get ; set ; }
72
+
73
+ /// <inheritdoc />
74
+ public IInlineScript Script { get ; set ; }
75
+
76
+ /// <inheritdoc />
77
+ public OnScriptError ? OnScriptError { get ; set ; }
57
78
}
58
79
59
80
[ DebuggerDisplay ( "{DebugDisplay}" ) ]
@@ -71,10 +92,11 @@ protected NumberPropertyDescriptorBase(FieldType type) : base(type) { }
71
92
bool ? INumberProperty . Coerce { get ; set ; }
72
93
INumericFielddata INumberProperty . Fielddata { get ; set ; }
73
94
bool ? INumberProperty . IgnoreMalformed { get ; set ; }
74
-
75
95
bool ? INumberProperty . Index { get ; set ; }
76
96
double ? INumberProperty . NullValue { get ; set ; }
77
97
double ? INumberProperty . ScalingFactor { get ; set ; }
98
+ IInlineScript INumberProperty . Script { get ; set ; }
99
+ OnScriptError ? INumberProperty . OnScriptError { get ; set ; }
78
100
79
101
public TDescriptor Type ( NumberType ? type ) => Assign ( type ? . GetStringValue ( ) , ( a , v ) => a . Type = v ) ;
80
102
@@ -93,6 +115,18 @@ public TDescriptor Fielddata(Func<NumericFielddataDescriptor, INumericFielddata>
93
115
Assign ( selector ( new NumericFielddataDescriptor ( ) ) , ( a , v ) => a . Fielddata = v ) ;
94
116
95
117
public TDescriptor ScalingFactor ( double ? scalingFactor ) => Assign ( scalingFactor , ( a , v ) => a . ScalingFactor = v ) ;
118
+
119
+ /// <inheritdoc cref="INumberProperty.Script" />
120
+ public TDescriptor Script ( IInlineScript inlineScript ) => Assign ( inlineScript , ( a , v ) => a . Script = v ) ;
121
+
122
+ /// <inheritdoc cref="INumberProperty.Script" />
123
+ public TDescriptor Script ( string source ) => Assign ( source , ( a , v ) => a . Script = new InlineScript ( source ) ) ;
124
+
125
+ /// <inheritdoc cref="INumberProperty.Script" />
126
+ public TDescriptor Script ( Func < InlineScriptDescriptor , IInlineScript > selector ) => Assign ( selector , ( a , v ) => a . Script = v ? . Invoke ( new InlineScriptDescriptor ( ) ) ) ;
127
+
128
+ /// <inheritdoc cref="INumberProperty.OnScriptError" />
129
+ public TDescriptor OnScriptError ( OnScriptError ? onScriptError ) => Assign ( onScriptError , ( a , v ) => a . OnScriptError = v ) ;
96
130
}
97
131
98
132
public class NumberPropertyDescriptor < T > : NumberPropertyDescriptorBase < NumberPropertyDescriptor < T > , INumberProperty , T >
0 commit comments