Skip to content

Commit 1360919

Browse files
authored
Remove Neighbors and use Union<Distance,int> for Precision (#4107)
Relates: #4091 This commit removes the Neighbors property from Completion field data type mapping and updates the Precision type to a Union<Distance,int>, to match the context suggest query inputs.
1 parent 81b8f9d commit 1360919

File tree

7 files changed

+37
-40
lines changed

7 files changed

+37
-40
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Runtime.Serialization;
2+
using Elasticsearch.Net.Utf8Json;
3+
4+
namespace Nest
5+
{
6+
[InterfaceDataContract]
7+
public interface IGeoSuggestContext : ISuggestContext
8+
{
9+
[DataMember(Name = "precision")]
10+
Union<Distance, int> Precision { get; set; }
11+
}
12+
13+
[DataContract]
14+
public class GeoSuggestContext : SuggestContextBase, IGeoSuggestContext
15+
{
16+
public Union<Distance, int> Precision { get; set; }
17+
public override string Type => "geo";
18+
}
19+
20+
[DataContract]
21+
public class GeoSuggestContextDescriptor<T>
22+
: SuggestContextDescriptorBase<GeoSuggestContextDescriptor<T>, IGeoSuggestContext, T>, IGeoSuggestContext
23+
where T : class
24+
{
25+
protected override string Type => "geo";
26+
27+
Union<Distance, int> IGeoSuggestContext.Precision { get; set; }
28+
29+
public GeoSuggestContextDescriptor<T> Precision(Distance precision) => Assign(precision, (a, v) => a.Precision = v);
30+
31+
public GeoSuggestContextDescriptor<T> Precision(int? precision) => Assign(precision, (a, v) => a.Precision = v);
32+
}
33+
}

src/Nest/Search/Suggesters/ContextSuggester/SuggestContextFormatter.cs renamed to src/Nest/Mapping/Types/Specialized/Completion/SuggestContextFormatter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Elasticsearch.Net.Utf8Json;
33
using Elasticsearch.Net.Utf8Json.Internal;
44

5-
65
namespace Nest
76
{
87
internal class SuggestContextFormatter : IJsonFormatter<ISuggestContext>

src/Nest/Search/Suggesters/ContextSuggester/GeoSuggestContext.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/Tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ public static PropertiesDescriptor<TProject> ProjectProperties<TProject>(Propert
347347
.Category(c => c
348348
.Name("color")
349349
)
350+
.GeoLocation(c => c
351+
.Name("geo")
352+
.Precision(1)
353+
)
350354
)
351355
)
352356
.Scalar(p => p.NumberOfCommits, n => n.Store())

0 commit comments

Comments
 (0)