|
| 1 | +using Newtonsoft.Json; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Linq; |
| 5 | +using System.Linq.Expressions; |
| 6 | +using System.Text; |
| 7 | + |
| 8 | +namespace Nest |
| 9 | +{ |
| 10 | + [JsonObject] |
| 11 | + public interface IGeoLocationSuggestContext : ISuggestContext |
| 12 | + { |
| 13 | + [JsonProperty("precision")] |
| 14 | + IEnumerable<string> Precision { get; set; } |
| 15 | + |
| 16 | + [JsonProperty("neighbors")] |
| 17 | + bool Neighbors { get; set; } |
| 18 | + |
| 19 | + [JsonProperty("default")] |
| 20 | + object Default { get; set; } |
| 21 | + } |
| 22 | + |
| 23 | + [JsonObject] |
| 24 | + public class GeoLocationSuggestContext : IGeoLocationSuggestContext |
| 25 | + { |
| 26 | + public string Type { get { return "geo"; } } |
| 27 | + |
| 28 | + public IEnumerable<string> Precision { get; set; } |
| 29 | + |
| 30 | + public bool Neighbors { get; set; } |
| 31 | + |
| 32 | + public PropertyPathMarker Path { get; set; } |
| 33 | + |
| 34 | + public object Default { get; set; } |
| 35 | + } |
| 36 | + |
| 37 | + public class GeoLocationSuggestDescriptor<T> |
| 38 | + where T : class |
| 39 | + { |
| 40 | + internal GeoLocationSuggestContext _Context = new GeoLocationSuggestContext(); |
| 41 | + |
| 42 | + public GeoLocationSuggestDescriptor<T> Precision(params string[] precisions) |
| 43 | + { |
| 44 | + this._Context.Precision = precisions; |
| 45 | + return this; |
| 46 | + } |
| 47 | + |
| 48 | + public GeoLocationSuggestDescriptor<T> Neighbors(bool neighbors = true) |
| 49 | + { |
| 50 | + this._Context.Neighbors = neighbors; |
| 51 | + return this; |
| 52 | + } |
| 53 | + |
| 54 | + public GeoLocationSuggestDescriptor<T> Path(string path) |
| 55 | + { |
| 56 | + this._Context.Path = path; |
| 57 | + return this; |
| 58 | + } |
| 59 | + |
| 60 | + public GeoLocationSuggestDescriptor<T> Path(Expression<Func<T, object>> objectPath) |
| 61 | + { |
| 62 | + this._Context.Path = objectPath; |
| 63 | + return this; |
| 64 | + } |
| 65 | + |
| 66 | + public GeoLocationSuggestDescriptor<T> Default(LatLon geoPoint) |
| 67 | + { |
| 68 | + this._Context.Default = geoPoint; |
| 69 | + return this; |
| 70 | + } |
| 71 | + |
| 72 | + public GeoLocationSuggestDescriptor<T> Default(string geoHash) |
| 73 | + { |
| 74 | + this._Context.Default = geoHash; |
| 75 | + return this; |
| 76 | + } |
| 77 | + } |
| 78 | +} |
0 commit comments