66
77namespace Nest
88{
9+ /// <summary>
10+ /// Converts a field in the currently ingested document to a different type,
11+ /// such as converting a string to an integer.
12+ /// If the field value is an array, all members will be converted.
13+ /// </summary>
914 [ InterfaceDataContract ]
1015 public interface IConvertProcessor : IProcessor
1116 {
17+ /// <summary>
18+ /// The field whose value is to be converted
19+ /// </summary>
1220 [ DataMember ( Name = "field" ) ]
1321 Field Field { get ; set ; }
1422
23+ /// <summary>
24+ /// The field to assign the converted value to, by default field is updated in-place
25+ /// </summary>
1526 [ DataMember ( Name = "target_field" ) ]
1627 Field TargetField { get ; set ; }
1728
29+ /// <summary>
30+ /// The type to convert the existing value to
31+ /// </summary>
1832 [ DataMember ( Name = "type" ) ]
1933 ConvertProcessorType ? Type { get ; set ; }
34+
35+ /// <summary>
36+ /// If <c>true</c> and <see cref="Field" /> does not exist or is null,
37+ /// the processor quietly exits without modifying the document. Default is <c>false</c>
38+ /// </summary>
39+ [ DataMember ( Name = "ignore_missing" ) ]
40+ bool ? IgnoreMissing { get ; set ; }
2041 }
2142
2243 public class ConvertProcessor : ProcessorBase , IConvertProcessor
2344 {
45+ /// <inheritdoc />
2446 public Field Field { get ; set ; }
47+ /// <inheritdoc />
2548 public Field TargetField { get ; set ; }
49+ /// <inheritdoc />
2650 public ConvertProcessorType ? Type { get ; set ; }
51+ /// <inheritdoc />
52+ public bool ? IgnoreMissing { get ; set ; }
53+ /// <inheritdoc />
2754 protected override string Name => "convert" ;
2855 }
2956
@@ -33,19 +60,28 @@ public class ConvertProcessorDescriptor<T> : ProcessorDescriptorBase<ConvertProc
3360 protected override string Name => "convert" ;
3461 Field IConvertProcessor . Field { get ; set ; }
3562 Field IConvertProcessor . TargetField { get ; set ; }
63+ bool ? IConvertProcessor . IgnoreMissing { get ; set ; }
3664 ConvertProcessorType ? IConvertProcessor . Type { get ; set ; }
3765
66+ /// <inheritdoc cref="IConvertProcessor.Field" />
3867 public ConvertProcessorDescriptor < T > Field ( Field field ) => Assign ( field , ( a , v ) => a . Field = v ) ;
3968
69+ /// <inheritdoc cref="IConvertProcessor.Field" />
4070 public ConvertProcessorDescriptor < T > Field < TValue > ( Expression < Func < T , TValue > > objectPath ) =>
4171 Assign ( objectPath , ( a , v ) => a . Field = v ) ;
4272
73+ /// <inheritdoc cref="IConvertProcessor.TargetField" />
4374 public ConvertProcessorDescriptor < T > TargetField ( Field field ) => Assign ( field , ( a , v ) => a . TargetField = v ) ;
4475
76+ /// <inheritdoc cref="IConvertProcessor.TargetField" />
4577 public ConvertProcessorDescriptor < T > TargetField < TValue > ( Expression < Func < T , TValue > > objectPath ) =>
4678 Assign ( objectPath , ( a , v ) => a . TargetField = v ) ;
4779
80+ /// <inheritdoc cref="IConvertProcessor.Type" />
4881 public ConvertProcessorDescriptor < T > Type ( ConvertProcessorType ? type ) => Assign ( type , ( a , v ) => a . Type = v ) ;
82+
83+ /// <inheritdoc cref="IConvertProcessor.IgnoreMissing" />
84+ public ConvertProcessorDescriptor < T > IgnoreMissing ( bool ? ignoreMissing = true ) => Assign ( ignoreMissing , ( a , v ) => a . IgnoreMissing = v ) ;
4985 }
5086
5187 [ StringEnum ]
@@ -54,9 +90,15 @@ public enum ConvertProcessorType
5490 [ EnumMember ( Value = "integer" ) ]
5591 Integer ,
5692
93+ [ EnumMember ( Value = "long" ) ]
94+ Long ,
95+
5796 [ EnumMember ( Value = "float" ) ]
5897 Float ,
5998
99+ [ EnumMember ( Value = "double" ) ]
100+ Double ,
101+
60102 [ EnumMember ( Value = "string" ) ]
61103 String ,
62104
0 commit comments