Skip to content

Commit 8322e25

Browse files
committed
Add support for numeric_resolution to date mapping
Closes #1449
1 parent a56b688 commit 8322e25

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

src/Nest/Domain/Mapping/Descriptors/DateMappingDescriptor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,11 @@ public DateMappingDescriptor<T> DocValues(bool docValues = true)
9494
this._Mapping.DocValues = docValues;
9595
return this;
9696
}
97+
98+
public DateMappingDescriptor<T> NumericResolution(NumericResolutionUnit unit)
99+
{
100+
this._Mapping.NumericResolution = unit;
101+
return this;
102+
}
97103
}
98104
}

src/Nest/Domain/Mapping/Types/DateMapping.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ public DateMapping():base("date")
4141

4242
[JsonProperty("doc_values")]
4343
public bool? DocValues { get; set; }
44+
45+
[JsonProperty("numeric_resolution")]
46+
public NumericResolutionUnit NumericResolution { get; set; }
4447
}
4548
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Runtime.Serialization;
7+
using System.Text;
8+
9+
namespace Nest
10+
{
11+
[JsonConverter(typeof(StringEnumConverter))]
12+
public enum NumericResolutionUnit
13+
{
14+
[EnumMember(Value = "milliseconds")]
15+
Milliseconds,
16+
[EnumMember(Value = "seconds")]
17+
Seconds
18+
}
19+
}

src/Nest/Nest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@
406406
<Compile Include="Enums\GeoShapeRelation.cs" />
407407
<Compile Include="Enums\HighlighterType.cs" />
408408
<Compile Include="Enums\NormsLoading.cs" />
409+
<Compile Include="Enums\NumericResolutionUnit.cs" />
409410
<Compile Include="Enums\RangeExecution.cs" />
410411
<Compile Include="Enums\RoutingAllocationEnableOption.cs" />
411412
<Compile Include="Enums\ScriptLang.cs" />

src/Tests/Nest.Tests.Unit/Core/Map/Properties/DateProperty.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"boost": 1.3,
1212
"null_value": "1986-03-08T00:00:00",
1313
"include_in_all": true,
14-
"ignore_malformed": true
14+
"ignore_malformed": true,
15+
"doc_values": true,
16+
"numeric_resolution": "seconds"
1517
}
1618
}
1719
}

src/Tests/Nest.Tests.Unit/Core/Map/Properties/PropertiesTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public void DateProperty()
9292
.PrecisionStep(4)
9393
.Store()
9494
.Boost(1.3)
95+
.DocValues()
96+
.NumericResolution(NumericResolutionUnit.Seconds)
9597
)
9698
)
9799
);

0 commit comments

Comments
 (0)