Skip to content

Commit e923785

Browse files
committed
added ignore_unmapped support to SortDescriptor
1 parent 675b06c commit e923785

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public void TestSort()
1717
.OnField(e => e.Country)
1818
.MissingLast()
1919
.Descending()
20+
.IgnoreUnmappedFields(true)
2021
);
2122
var json = TestElasticClient.Serialize(s);
2223
var expected = @"
@@ -26,7 +27,8 @@ public void TestSort()
2627
sort: {
2728
country: {
2829
missing: ""_last"",
29-
order: ""desc""
30+
order: ""desc"",
31+
ignore_unmapped: true
3032
}
3133
}
3234
}";

src/Nest/DSL/SortDescriptor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class SortDescriptor<T> where T : class
2323

2424
[JsonProperty("nested_path")]
2525
internal string _NestedPath { get; set; }
26+
27+
[JsonProperty("ignore_unmapped")]
28+
internal bool? _IgnoreUnmappedFields { get; set; }
2629

2730
public virtual SortDescriptor<T> OnField(string field)
2831
{
@@ -60,6 +63,11 @@ public virtual SortDescriptor<T> MissingValue(string value)
6063
this._Missing = value;
6164
return this;
6265
}
66+
public virtual SortDescriptor<T> IgnoreUnmappedFields(bool ignore = true)
67+
{
68+
this._IgnoreUnmappedFields = ignore;
69+
return this;
70+
}
6371
public virtual SortDescriptor<T> Ascending()
6472
{
6573
this._Order = "asc";

0 commit comments

Comments
 (0)