Skip to content

Commit 8db6849

Browse files
committed
Merge pull request #1112 from vovikdrg/develop
Missing and Replaced properties
2 parents 741d690 + 0ef0290 commit 8db6849

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/Nest/DSL/Search/SortFieldDescriptor.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ public interface IFieldSort : ISort
125125

126126
[JsonProperty("ignore_unmapped")]
127127
bool? IgnoreUnmappedFields { get; set; }
128+
129+
[JsonProperty("unmapped_type")]
130+
FieldType? UnmappedType { get; set; }
128131
}
129132

130133
public class Sort : SortBase, IFieldSort
131134
{
132135
public PropertyPathMarker Field { get; set; }
133136
public bool? IgnoreUnmappedFields { get; set; }
137+
public FieldType? UnmappedType { get; set; }
134138
}
135139

136140
public class SortFieldDescriptor<T> : SortDescriptorBase<T, SortFieldDescriptor<T>>, IFieldSort where T : class
@@ -140,8 +144,9 @@ public class SortFieldDescriptor<T> : SortDescriptorBase<T, SortFieldDescriptor<
140144
PropertyPathMarker IFieldSort.Field { get; set; }
141145

142146
bool? IFieldSort.IgnoreUnmappedFields { get; set; }
147+
FieldType? IFieldSort.UnmappedType { get; set; }
143148

144-
public virtual SortFieldDescriptor<T> OnField(string field)
149+
public virtual SortFieldDescriptor<T> OnField(string field)
145150
{
146151
Self.Field = field;
147152
return this;
@@ -170,7 +175,13 @@ public virtual SortFieldDescriptor<T> MissingValue(string value)
170175
Self.Missing = value;
171176
return this;
172177
}
178+
public virtual SortFieldDescriptor<T> UnmappedType(FieldType type)
179+
{
180+
Self.UnmappedType = type;
181+
return this;
182+
}
173183

184+
[Obsolete("Deprecated in 1.4.0 use UnmappedType")]
174185
public virtual SortFieldDescriptor<T> IgnoreUnmappedFields(bool ignore = true)
175186
{
176187
Self.IgnoreUnmappedFields = ignore;

src/Nest/Domain/Analysis/TokenFilter/ShingleTokenFilter.cs

+6
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,11 @@ public ShingleTokenFilter() : base("shingle")
4343
/// </summary>
4444
[JsonProperty("token_separator")]
4545
public string TokenSeparator { get; set; }
46+
47+
/// <summary>
48+
/// The string to use as a replacement for each position at which there is no actual token in the stream. For instance this string is used if the position increment is greater than one when a stop filter is used together with the shingle filter. Defaults to "_"
49+
/// </summary>
50+
[JsonProperty("filler_token")]
51+
public string FillerToken { get; set; }
4652
}
4753
}

src/Tests/Nest.Tests.Unit/Search/Sorting/SortTests.cs

+24
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ public void TestSort()
3737
Assert.True(json.JsonEquals(expected), json);
3838
}
3939

40+
[Test]
41+
public void TestSortWithUnmappedType()
42+
{
43+
var s = new SearchDescriptor<ElasticsearchProject>()
44+
.From(0)
45+
.Size(10)
46+
.Sort(sort => sort
47+
.OnField(e => e.DoubleValue)
48+
.UnmappedType(FieldType.Long)
49+
);
50+
var expected = @"
51+
{
52+
from: 0,
53+
size: 10,
54+
sort: [
55+
{
56+
doubleValue : { unmapped_type : ""long"" }
57+
}
58+
]
59+
}";
60+
var json = TestElasticClient.Serialize(s);
61+
Assert.True(json.JsonEquals(expected), json);
62+
}
63+
4064
[Test]
4165
public void TestSortOnSortField()
4266
{

0 commit comments

Comments
 (0)