diff --git a/src/Nest/DSL/PutMappingDescriptor.cs b/src/Nest/DSL/PutMappingDescriptor.cs index 81f5bad16d6..26af8bf8f4f 100644 --- a/src/Nest/DSL/PutMappingDescriptor.cs +++ b/src/Nest/DSL/PutMappingDescriptor.cs @@ -265,12 +265,20 @@ public PutMappingDescriptor RoutingField(Func()); return this; } + public PutMappingDescriptor TimestampField(Func, ITimestampFieldMapping> timestampMapper) { timestampMapper.ThrowIfNull("timestampMapper"); Self.Mapping.TimestampFieldMapping = timestampMapper(new TimestampFieldMappingDescriptor()); return this; } + + public PutMappingDescriptor FieldNamesField(Func, IFieldNamesFieldMapping> fieldNamesMapper) + { + Self.Mapping.FieldNamesFieldMapping = fieldNamesMapper == null ? null : fieldNamesMapper(new FieldNamesFieldMappingDescriptor()); + return this; + } + public PutMappingDescriptor TtlField(Func ttlFieldMapper) { ttlFieldMapper.ThrowIfNull("ttlFieldMapper"); diff --git a/src/Nest/Domain/Mapping/SpecialFields/FieldNamesMapping.cs b/src/Nest/Domain/Mapping/SpecialFields/FieldNamesMapping.cs new file mode 100644 index 00000000000..3da4b1755ec --- /dev/null +++ b/src/Nest/Domain/Mapping/SpecialFields/FieldNamesMapping.cs @@ -0,0 +1,34 @@ +using System; +using Newtonsoft.Json; +using System.Linq.Expressions; +using Nest.Resolvers.Converters; + +namespace Nest +{ + [JsonConverter(typeof(ReadAsTypeConverter))] + public interface IFieldNamesFieldMapping : ISpecialField + { + [JsonProperty("enabled")] + bool Enabled { get; set; } + } + + public class FieldNamesFieldMapping : IFieldNamesFieldMapping + { + public bool Enabled { get; set; } + } + + + public class FieldNamesFieldMappingDescriptor : IFieldNamesFieldMapping + { + private IFieldNamesFieldMapping Self { get { return this; } } + + bool IFieldNamesFieldMapping.Enabled { get; set;} + + public FieldNamesFieldMappingDescriptor Enabled(bool enabled = true) + { + Self.Enabled = enabled; + return this; + } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Mapping/Types/RootObjectMapping.cs b/src/Nest/Domain/Mapping/Types/RootObjectMapping.cs index a86ae3e7700..d2c0bb8bc45 100644 --- a/src/Nest/Domain/Mapping/Types/RootObjectMapping.cs +++ b/src/Nest/Domain/Mapping/Types/RootObjectMapping.cs @@ -65,6 +65,9 @@ public class RootObjectMapping : ObjectMapping [JsonProperty("_timestamp")] public ITimestampFieldMapping TimestampFieldMapping { get; set; } + [JsonProperty("_field_names")] + public IFieldNamesFieldMapping FieldNamesFieldMapping { get; set; } + [JsonProperty("_ttl")] public ITtlFieldMapping TtlFieldMappingDescriptor { get; set; } diff --git a/src/Nest/Nest.csproj b/src/Nest/Nest.csproj index fd395f9187a..cff06509054 100644 --- a/src/Nest/Nest.csproj +++ b/src/Nest/Nest.csproj @@ -153,6 +153,7 @@ + diff --git a/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesFieldTests.cs b/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesFieldTests.cs new file mode 100644 index 00000000000..8578fd016e3 --- /dev/null +++ b/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesFieldTests.cs @@ -0,0 +1,19 @@ +using NUnit.Framework; +using Nest.Tests.MockData.Domain; +using System.Reflection; + +namespace Nest.Tests.Unit.Core.Map.FieldNamesField +{ + [TestFixture] + public class FieldNamesFieldTests : BaseJsonTests + { + [Test] + public void FieldNamesMapping() + { + var result = this._client.Map(m => m + .FieldNamesField(a => a .Enabled(false)) + ); + this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod()); + } + } +} diff --git a/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesMapping.json b/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesMapping.json new file mode 100644 index 00000000000..8c85b1341be --- /dev/null +++ b/src/Tests/Nest.Tests.Unit/Core/Map/FieldNamesField/FieldNamesMapping.json @@ -0,0 +1,7 @@ + { + "elasticsearchprojects": { + "_field_names": { + "enabled": false + } + } +} \ No newline at end of file diff --git a/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj b/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj index f131b75c189..f60df1d1e1e 100644 --- a/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj +++ b/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj @@ -199,6 +199,7 @@ Always + @@ -637,6 +638,9 @@ Always + + Always + Always