-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Circle processor #4161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Circle processor #4161
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Runtime.Serialization; | ||
using Elasticsearch.Net; | ||
using Elasticsearch.Net.Utf8Json; | ||
|
||
namespace Nest | ||
{ | ||
[StringEnum] | ||
public enum ShapeType | ||
{ | ||
[EnumMember(Value = "geo_shape")] | ||
GeoShape, | ||
|
||
[EnumMember(Value = "shape")] | ||
Shape | ||
} | ||
|
||
[InterfaceDataContract] | ||
public interface ICircleProcessor : IProcessor | ||
{ | ||
/// <summary> | ||
/// The string-valued field to trim whitespace from. | ||
/// </summary> | ||
[DataMember(Name ="field")] | ||
Field Field { get; set; } | ||
|
||
/// <summary> | ||
/// The field to assign the polygon shape to, by default field is updated in-place. | ||
/// </summary> | ||
[DataMember(Name ="target_field")] | ||
Field TargetField { get; set; } | ||
|
||
/// <summary> | ||
/// If true and field does not exist, the processor quietly exits without modifying the document. | ||
/// </summary> | ||
[DataMember(Name = "ignore_missing")] | ||
bool? IgnoreMissing { get; set; } | ||
|
||
/// <summary> | ||
/// The difference between the resulting inscribed distance from center to side and the circle’s radius | ||
/// (measured in meters for geo_shape, unit-less for shape) | ||
/// </summary> | ||
[DataMember(Name = "error_distance")] | ||
double? ErrorDistance { get; set; } | ||
|
||
/// <summary> | ||
/// Which field mapping type is to be used when processing the circle. | ||
/// </summary> | ||
[DataMember(Name = "shape_type")] | ||
ShapeType? ShapeType { get; set; } | ||
} | ||
|
||
public class CircleProcessor : ProcessorBase, ICircleProcessor | ||
{ | ||
/// <inheritdoc /> | ||
public Field Field { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public Field TargetField { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public bool? IgnoreMissing { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public double? ErrorDistance { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public ShapeType? ShapeType { get; set; } | ||
|
||
/// <inheritdoc /> | ||
protected override string Name => "circle"; | ||
} | ||
|
||
public class CircleProcessorDescriptor<T> | ||
: ProcessorDescriptorBase<CircleProcessorDescriptor<T>, ICircleProcessor>, ICircleProcessor | ||
where T : class | ||
{ | ||
protected override string Name => "circle"; | ||
|
||
Field ICircleProcessor.Field { get; set; } | ||
Field ICircleProcessor.TargetField { get; set; } | ||
bool? ICircleProcessor.IgnoreMissing { get; set; } | ||
double? ICircleProcessor.ErrorDistance { get; set; } | ||
ShapeType? ICircleProcessor.ShapeType { get; set; } | ||
|
||
/// <inheritdoc cref="ICircleProcessor.Field" /> | ||
public CircleProcessorDescriptor<T> Field(Field field) => Assign(field, (a, v) => a.Field = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.Field" /> | ||
public CircleProcessorDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> objectPath) => | ||
Assign(objectPath, (a, v) => a.Field = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.TargetField" /> | ||
public CircleProcessorDescriptor<T> TargetField(Field field) => Assign(field, (a, v) => a.TargetField = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.TargetField" /> | ||
public CircleProcessorDescriptor<T> TargetField<TValue>(Expression<Func<T, TValue>> objectPath) => | ||
Assign(objectPath, (a, v) => a.TargetField = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.IgnoreMissing"> | ||
public CircleProcessorDescriptor<T> IgnoreMissing(bool? ignoreMissing = true) => | ||
Assign(ignoreMissing, (a, v) => a.IgnoreMissing = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.IgnoreMissing"> | ||
public CircleProcessorDescriptor<T> ErrorDistance(double? errorDistance) => | ||
Assign(errorDistance, (a, v) => a.ErrorDistance = v); | ||
|
||
/// <inheritdoc cref="ICircleProcessor.ShapeType"> | ||
public CircleProcessorDescriptor<T> ShapeType(ShapeType? shapeType) => | ||
Assign(shapeType, (a, v) => a.ShapeType = v); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.