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