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 [ JsonObject ( MemberSerialization . OptIn ) ]
1015 [ JsonConverter ( typeof ( ProcessorJsonConverter < ConvertProcessor > ) ) ]
1116 public interface IConvertProcessor : IProcessor
1217 {
18+ /// <summary>
19+ /// The field whose value is to be converted
20+ /// </summary>
1321 [ JsonProperty ( "field" ) ]
1422 Field Field { get ; set ; }
1523
24+ /// <summary>
25+ /// The field to assign the converted value to, by default field is updated in-place
26+ /// </summary>
1627 [ JsonProperty ( "target_field" ) ]
1728 Field TargetField { get ; set ; }
1829
30+ /// <summary>
31+ /// The type to convert the existing value to
32+ /// </summary>
1933 [ JsonProperty ( "type" ) ]
2034 ConvertProcessorType ? Type { get ; set ; }
35+
36+ /// <summary>
37+ /// If <c>true</c> and <see cref="Field" /> does not exist or is null,
38+ /// the processor quietly exits without modifying the document. Default is <c>false</c>
39+ /// </summary>
40+ [ JsonProperty ( "ignore_missing" ) ]
41+ bool ? IgnoreMissing { get ; set ; }
2142 }
2243
2344 public class ConvertProcessor : ProcessorBase , IConvertProcessor
2445 {
46+ /// <inheritdoc />
2547 public Field Field { get ; set ; }
48+ /// <inheritdoc />
2649 public Field TargetField { get ; set ; }
50+ /// <inheritdoc />
2751 public ConvertProcessorType ? Type { get ; set ; }
52+ /// <inheritdoc />
53+ public bool ? IgnoreMissing { get ; set ; }
54+ /// <inheritdoc />
2855 protected override string Name => "convert" ;
2956 }
3057
@@ -34,19 +61,28 @@ public class ConvertProcessorDescriptor<T> : ProcessorDescriptorBase<ConvertProc
3461 protected override string Name => "convert" ;
3562 Field IConvertProcessor . Field { get ; set ; }
3663 Field IConvertProcessor . TargetField { get ; set ; }
64+ bool ? IConvertProcessor . IgnoreMissing { get ; set ; }
3765 ConvertProcessorType ? IConvertProcessor . Type { get ; set ; }
3866
67+ /// <inheritdoc cref="IConvertProcessor.Field" />
3968 public ConvertProcessorDescriptor < T > Field ( Field field ) => Assign ( field , ( a , v ) => a . Field = v ) ;
4069
70+ /// <inheritdoc cref="IConvertProcessor.Field" />
4171 public ConvertProcessorDescriptor < T > Field ( Expression < Func < T , object > > objectPath ) =>
4272 Assign ( objectPath , ( a , v ) => a . Field = v ) ;
4373
74+ /// <inheritdoc cref="IConvertProcessor.TargetField" />
4475 public ConvertProcessorDescriptor < T > TargetField ( Field field ) => Assign ( field , ( a , v ) => a . TargetField = v ) ;
4576
77+ /// <inheritdoc cref="IConvertProcessor.TargetField" />
4678 public ConvertProcessorDescriptor < T > TargetField ( Expression < Func < T , object > > objectPath ) =>
4779 Assign ( objectPath , ( a , v ) => a . TargetField = v ) ;
4880
81+ /// <inheritdoc cref="IConvertProcessor.Type" />
4982 public ConvertProcessorDescriptor < T > Type ( ConvertProcessorType ? type ) => Assign ( type , ( a , v ) => a . Type = v ) ;
83+
84+ /// <inheritdoc cref="IConvertProcessor.IgnoreMissing" />
85+ public ConvertProcessorDescriptor < T > IgnoreMissing ( bool ? ignoreMissing = true ) => Assign ( ignoreMissing , ( a , v ) => a . IgnoreMissing = v ) ;
5086 }
5187
5288 [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
@@ -55,9 +91,15 @@ public enum ConvertProcessorType
5591 [ EnumMember ( Value = "integer" ) ]
5692 Integer ,
5793
94+ [ EnumMember ( Value = "long" ) ]
95+ Long ,
96+
5897 [ EnumMember ( Value = "float" ) ]
5998 Float ,
6099
100+ [ EnumMember ( Value = "double" ) ]
101+ Double ,
102+
61103 [ EnumMember ( Value = "string" ) ]
62104 String ,
63105
0 commit comments