Skip to content

Commit 5cfe1c8

Browse files
committed
fix #990 nullreference when using the DateMappingDescriptor multi .Fields()
1 parent 5308d37 commit 5cfe1c8

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

Diff for: src/Nest/Domain/Mapping/Types/MultiFieldMapping.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public class MultiFieldMapping : IElasticType
1010
{
1111
private readonly TypeNameMarker _defaultType;
1212

13-
public MultiFieldMapping()
14-
: this("multi_field")
13+
public MultiFieldMapping()
1514
{
1615
this.Fields = new Dictionary<PropertyNameMarker, IElasticCoreType>();
16+
_defaultType = "multi_field";
1717
}
1818

19-
protected MultiFieldMapping(TypeNameMarker defaultType)
19+
protected MultiFieldMapping(TypeNameMarker defaultType) : this()
2020
{
2121
_defaultType = defaultType;
2222
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Elasticsearch.Net;
6+
using Nest.Tests.MockData.Domain;
7+
using NUnit.Framework;
8+
9+
namespace Nest.Tests.Unit.Reproduce
10+
{
11+
/// <summary>
12+
/// tests to reproduce reported errors
13+
/// </summary>
14+
[TestFixture]
15+
public class Reproduce990Tests : BaseJsonTests
16+
{
17+
[Test]
18+
public void DateMappingShouldNotTrow()
19+
{
20+
Assert.DoesNotThrow(() =>
21+
{
22+
var result = _client.Map<ElasticsearchProject>(p => p
23+
.DynamicTemplates(d => d
24+
.Add(dt => dt
25+
.Name("date_template")
26+
.Match("*_date")
27+
.MatchMappingType("date")
28+
.Mapping(mp => mp
29+
.Date(date => date
30+
.Format("basic_date || date|| yyyy/MM/dd || dd/MM/yyyy || dd-MM-yyyy || MM/dd/yyyy || MM-dd-yyyy")
31+
.Fields(f => f
32+
.String(fs => fs
33+
.Name("raw")
34+
.Analyzer("number_delimiter")
35+
)
36+
)
37+
)
38+
)
39+
)
40+
)
41+
);
42+
});
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)