Skip to content

Commit 37b9546

Browse files
John Danielsgmarz
authored andcommitted
Fix issues with deserializing mappings when retrieving mappings from the server.
We need to make sure that we can deserialize the interfaces on the RootObjectMapping, which requires specifying ResolveAsTypeConverter on all the appropriate interfaces. I added a test as well, though I'm not sure it's in the right place, and I added a Deserialize function on TestElasticClient to make it easier to roundtrip the serialization.
1 parent 682bc52 commit 37b9546

13 files changed

+136
-6
lines changed

src/Nest/Domain/Mapping/SpecialFields/AnalyzerFieldMapping.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Nest
77
{
8+
[JsonConverter(typeof(ReadAsTypeConverter<AnalyzerFieldMapping>))]
89
public interface IAnalyzerFieldMapping : ISpecialField
910
{
1011
[JsonProperty("index"), JsonConverter(typeof(YesNoBoolConverter))]

src/Nest/Domain/Mapping/SpecialFields/BoostFieldMapping.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Linq.Expressions;
33
using Newtonsoft.Json;
4+
using Nest.Resolvers.Converters;
45

56
namespace Nest
67
{
8+
[JsonConverter(typeof(ReadAsTypeConverter<BoostFieldMapping>))]
79
public interface IBoostFieldMapping : ISpecialField
810
{
911
[JsonProperty("name")]

src/Nest/Domain/Mapping/SpecialFields/IdFieldMapping.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using Newtonsoft.Json;
1+
using Nest.Resolvers.Converters;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
[JsonConverter(typeof(ReadAsTypeConverter<IdFieldMapping>))]
57
public interface IIdFieldMapping : ISpecialField
68
{
79
[JsonProperty("path")]

src/Nest/Domain/Mapping/SpecialFields/IndexFieldMapping.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using Newtonsoft.Json;
1+
using Nest.Resolvers.Converters;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
[JsonConverter(typeof(ReadAsTypeConverter<IndexFieldMapping>))]
57
public interface IIndexFieldMapping : ISpecialField
68
{
79
[JsonProperty("enabled")]

src/Nest/Domain/Mapping/SpecialFields/RoutingFieldMapping.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using Newtonsoft.Json;
33
using System.Linq.Expressions;
4+
using Nest.Resolvers.Converters;
45

56
namespace Nest
67
{
8+
[JsonConverter(typeof(ReadAsTypeConverter<RoutingFieldMapping>))]
79
public interface IRoutingFieldMapping : ISpecialField
810
{
911
[JsonProperty("required")]

src/Nest/Domain/Mapping/SpecialFields/SizeFieldMapping.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using Newtonsoft.Json;
1+
using Nest.Resolvers.Converters;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
[JsonConverter(typeof(ReadAsTypeConverter<SizeFieldMapping>))]
57
public interface ISizeFieldMapping : ISpecialField
68
{
79
[JsonProperty("enabled")]

src/Nest/Domain/Mapping/SpecialFields/SourceFieldMapping.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Nest.Resolvers.Converters;
34

45
namespace Nest
56
{
7+
[JsonConverter(typeof(ReadAsTypeConverter<SourceFieldMapping>))]
68
public interface ISourceFieldMapping : ISpecialField
79
{
810
[JsonProperty("enabled")]

src/Nest/Domain/Mapping/SpecialFields/TimestampFieldMapping.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using Newtonsoft.Json;
33
using System.Linq.Expressions;
4+
using Nest.Resolvers.Converters;
45

56
namespace Nest
67
{
8+
[JsonConverter(typeof(ReadAsTypeConverter<TimestampFieldMapping>))]
79
public interface ITimestampFieldMapping : ISpecialField
810
{
911
[JsonProperty("enabled")]

src/Nest/Domain/Mapping/SpecialFields/TtlFieldMapping.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using Newtonsoft.Json;
1+
using Nest.Resolvers.Converters;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
[JsonConverter(typeof(ReadAsTypeConverter<TtlFieldMapping>))]
57
public interface ITtlFieldMapping : ISpecialField
68
{
79
[JsonProperty("enabled")]

src/Nest/Domain/Mapping/SpecialFields/TypeFieldMapping.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using Newtonsoft.Json;
1+
using Nest.Resolvers.Converters;
2+
using Newtonsoft.Json;
23
using Newtonsoft.Json.Converters;
34

45
namespace Nest
56
{
7+
[JsonConverter(typeof(ReadAsTypeConverter<TypeFieldMapping>))]
68
public interface ITypeFieldMapping : ISpecialField
79
{
810
[JsonProperty("index"), JsonConverter(typeof(StringEnumConverter))]

0 commit comments

Comments
 (0)