Skip to content

Commit 702d27a

Browse files
committed
Merge pull request #1384 from elastic/feature/range-format
fix #1343 add format to range filter and query
2 parents 7cb1309 + 8299f14 commit 702d27a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Nest/DSL/Filter/RangeFilterDescriptor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public interface IRangeFilter : IFieldNameFilter
3232
[JsonProperty("time_zone")]
3333
string TimeZone { get; set; }
3434

35+
[JsonProperty("format")]
36+
string Format { get; set; }
37+
3538
[JsonProperty("execution")]
3639
RangeExecution? Execution { get; set; }
3740
}
@@ -47,6 +50,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
4750
public string GreaterThan { get; set; }
4851
public string LowerThan { get; set; }
4952
public string TimeZone { get; set; }
53+
public string Format { get; set; }
5054
public RangeExecution? Execution { get; set; }
5155
public PropertyPathMarker Field { get; set; }
5256
}
@@ -63,6 +67,8 @@ public class RangeFilterDescriptor<T> : FilterBase, IRangeFilter where T : class
6367

6468
string IRangeFilter.TimeZone { get; set; }
6569

70+
string IRangeFilter.Format { get; set; }
71+
6672
RangeExecution? IRangeFilter.Execution { get; set; }
6773

6874
PropertyPathMarker IFieldNameFilter.Field { get; set; }
@@ -196,6 +202,12 @@ public RangeFilterDescriptor<T> LowerOrEquals(DateTime? to, string format = "yyy
196202
return this;
197203
}
198204

205+
public RangeFilterDescriptor<T> Format(string format)
206+
{
207+
this.Self.Format = format;
208+
return this;
209+
}
210+
199211
public RangeFilterDescriptor<T> TimeZone(string timeZone)
200212
{
201213
this.Self.TimeZone = timeZone;

src/Nest/DSL/Query/RangeQueryDescriptor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public interface IRangeQuery : IFieldNameQuery
3333
[JsonProperty("time_zone")]
3434
string TimeZone { get; set; }
3535

36+
[JsonProperty("format")]
37+
string Format { get; set; }
38+
3639
PropertyPathMarker Field { get; set; }
3740
}
3841
public class RangeQuery : PlainQuery, IRangeQuery
@@ -61,6 +64,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
6164
public bool? Cache { get; set; }
6265
public string Name { get; set; }
6366
public string TimeZone { get; set; }
67+
public string Format { get; set; }
6468
public PropertyPathMarker Field { get; set; }
6569
}
6670
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
@@ -82,6 +86,8 @@ public class RangeQueryDescriptor<T> : IRangeQuery where T : class
8286

8387
string IRangeQuery.TimeZone { get; set; }
8488

89+
string IRangeQuery.Format { get; set; }
90+
8591
PropertyPathMarker IRangeQuery.Field { get; set; }
8692

8793
bool IQuery.IsConditionless
@@ -210,5 +216,12 @@ public RangeQueryDescriptor<T> TimeZone(string timeZone)
210216
return this;
211217
}
212218

219+
public RangeQueryDescriptor<T> Format(string format)
220+
{
221+
this.Self.Format = format;
222+
return this;
223+
}
224+
225+
213226
}
214227
}

0 commit comments

Comments
 (0)