|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq.Expressions; |
| 4 | +using System.Runtime.Serialization; |
| 5 | +using Elasticsearch.Net; |
| 6 | +using Elasticsearch.Net.Utf8Json; |
| 7 | + |
| 8 | +namespace Nest |
| 9 | +{ |
| 10 | + [StringEnum] |
| 11 | + public enum ShapeType |
| 12 | + { |
| 13 | + [EnumMember(Value = "geo_shape")] |
| 14 | + GeoShape, |
| 15 | + |
| 16 | + [EnumMember(Value = "shape")] |
| 17 | + Shape |
| 18 | + } |
| 19 | + |
| 20 | + [InterfaceDataContract] |
| 21 | + public interface ICircleProcessor : IProcessor |
| 22 | + { |
| 23 | + /// <summary> |
| 24 | + /// The string-valued field to trim whitespace from. |
| 25 | + /// </summary> |
| 26 | + [DataMember(Name ="field")] |
| 27 | + Field Field { get; set; } |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// The field to assign the polygon shape to, by default field is updated in-place. |
| 31 | + /// </summary> |
| 32 | + [DataMember(Name ="target_field")] |
| 33 | + Field TargetField { get; set; } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// If true and field does not exist, the processor quietly exits without modifying the document. |
| 37 | + /// </summary> |
| 38 | + [DataMember(Name = "ignore_missing")] |
| 39 | + bool? IgnoreMissing { get; set; } |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// The difference between the resulting inscribed distance from center to side and the circle’s radius |
| 43 | + /// (measured in meters for geo_shape, unit-less for shape) |
| 44 | + /// </summary> |
| 45 | + [DataMember(Name = "error_distance")] |
| 46 | + double? ErrorDistance { get; set; } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Which field mapping type is to be used when processing the circle. |
| 50 | + /// </summary> |
| 51 | + [DataMember(Name = "shape_type")] |
| 52 | + ShapeType? ShapeType { get; set; } |
| 53 | + } |
| 54 | + |
| 55 | + public class CircleProcessor : ProcessorBase, ICircleProcessor |
| 56 | + { |
| 57 | + /// <inheritdoc /> |
| 58 | + public Field Field { get; set; } |
| 59 | + |
| 60 | + /// <inheritdoc /> |
| 61 | + public Field TargetField { get; set; } |
| 62 | + |
| 63 | + /// <inheritdoc /> |
| 64 | + public bool? IgnoreMissing { get; set; } |
| 65 | + |
| 66 | + /// <inheritdoc /> |
| 67 | + public double? ErrorDistance { get; set; } |
| 68 | + |
| 69 | + /// <inheritdoc /> |
| 70 | + public ShapeType? ShapeType { get; set; } |
| 71 | + |
| 72 | + /// <inheritdoc /> |
| 73 | + protected override string Name => "circle"; |
| 74 | + } |
| 75 | + |
| 76 | + public class CircleProcessorDescriptor<T> |
| 77 | + : ProcessorDescriptorBase<CircleProcessorDescriptor<T>, ICircleProcessor>, ICircleProcessor |
| 78 | + where T : class |
| 79 | + { |
| 80 | + protected override string Name => "circle"; |
| 81 | + |
| 82 | + Field ICircleProcessor.Field { get; set; } |
| 83 | + Field ICircleProcessor.TargetField { get; set; } |
| 84 | + bool? ICircleProcessor.IgnoreMissing { get; set; } |
| 85 | + double? ICircleProcessor.ErrorDistance { get; set; } |
| 86 | + ShapeType? ICircleProcessor.ShapeType { get; set; } |
| 87 | + |
| 88 | + /// <inheritdoc cref="ICircleProcessor.Field" /> |
| 89 | + public CircleProcessorDescriptor<T> Field(Field field) => Assign(field, (a, v) => a.Field = v); |
| 90 | + |
| 91 | + /// <inheritdoc cref="ICircleProcessor.Field" /> |
| 92 | + public CircleProcessorDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> objectPath) => |
| 93 | + Assign(objectPath, (a, v) => a.Field = v); |
| 94 | + |
| 95 | + /// <inheritdoc cref="ICircleProcessor.TargetField" /> |
| 96 | + public CircleProcessorDescriptor<T> TargetField(Field field) => Assign(field, (a, v) => a.TargetField = v); |
| 97 | + |
| 98 | + /// <inheritdoc cref="ICircleProcessor.TargetField" /> |
| 99 | + public CircleProcessorDescriptor<T> TargetField<TValue>(Expression<Func<T, TValue>> objectPath) => |
| 100 | + Assign(objectPath, (a, v) => a.TargetField = v); |
| 101 | + |
| 102 | + /// <inheritdoc cref="ICircleProcessor.IgnoreMissing"> |
| 103 | + public CircleProcessorDescriptor<T> IgnoreMissing(bool? ignoreMissing = true) => |
| 104 | + Assign(ignoreMissing, (a, v) => a.IgnoreMissing = v); |
| 105 | + |
| 106 | + /// <inheritdoc cref="ICircleProcessor.IgnoreMissing"> |
| 107 | + public CircleProcessorDescriptor<T> ErrorDistance(double? errorDistance) => |
| 108 | + Assign(errorDistance, (a, v) => a.ErrorDistance = v); |
| 109 | + |
| 110 | + /// <inheritdoc cref="ICircleProcessor.ShapeType"> |
| 111 | + public CircleProcessorDescriptor<T> ShapeType(ShapeType? shapeType) => |
| 112 | + Assign(shapeType, (a, v) => a.ShapeType = v); |
| 113 | + } |
| 114 | +} |
0 commit comments