Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Nest/DSL/PutMappingDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,20 @@ public PutMappingDescriptor<T> RoutingField(Func<RoutingFieldMappingDescriptor<T
Self.Mapping.RoutingFieldMapping = routingMapper(new RoutingFieldMappingDescriptor<T>());
return this;
}

public PutMappingDescriptor<T> TimestampField(Func<TimestampFieldMappingDescriptor<T>, ITimestampFieldMapping> timestampMapper)
{
timestampMapper.ThrowIfNull("timestampMapper");
Self.Mapping.TimestampFieldMapping = timestampMapper(new TimestampFieldMappingDescriptor<T>());
return this;
}

public PutMappingDescriptor<T> FieldNamesField(Func<FieldNamesFieldMappingDescriptor<T>, IFieldNamesFieldMapping> fieldNamesMapper)
{
Self.Mapping.FieldNamesFieldMapping = fieldNamesMapper == null ? null : fieldNamesMapper(new FieldNamesFieldMappingDescriptor<T>());
return this;
}

public PutMappingDescriptor<T> TtlField(Func<TtlFieldMappingDescriptor, ITtlFieldMapping> ttlFieldMapper)
{
ttlFieldMapper.ThrowIfNull("ttlFieldMapper");
Expand Down
34 changes: 34 additions & 0 deletions src/Nest/Domain/Mapping/SpecialFields/FieldNamesMapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using Newtonsoft.Json;
using System.Linq.Expressions;
using Nest.Resolvers.Converters;

namespace Nest
{
[JsonConverter(typeof(ReadAsTypeConverter<FieldNamesFieldMapping>))]
public interface IFieldNamesFieldMapping : ISpecialField
{
[JsonProperty("enabled")]
bool Enabled { get; set; }
}

public class FieldNamesFieldMapping : IFieldNamesFieldMapping
{
public bool Enabled { get; set; }
}


public class FieldNamesFieldMappingDescriptor<T> : IFieldNamesFieldMapping
{
private IFieldNamesFieldMapping Self { get { return this; } }

bool IFieldNamesFieldMapping.Enabled { get; set;}

public FieldNamesFieldMappingDescriptor<T> Enabled(bool enabled = true)
{
Self.Enabled = enabled;
return this;
}

}
}
3 changes: 3 additions & 0 deletions src/Nest/Domain/Mapping/Types/RootObjectMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
1 change: 1 addition & 0 deletions src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<Compile Include="Domain\Geo\MultiPolygonGeoShape.cs" />
<Compile Include="Domain\Geo\PointGeoShape.cs" />
<Compile Include="Domain\Geo\PolygonGeoShape.cs" />
<Compile Include="Domain\Mapping\SpecialFields\FieldNamesMapping.cs" />
<Compile Include="Domain\Mapping\SubMappings\FieldData\FieldDataFilter.cs" />
<Compile Include="Domain\Mapping\SubMappings\FieldData\FieldDataFrequencyFilter.cs" />
<Compile Include="Domain\Mapping\SubMappings\FieldData\FieldDataMapping.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ElasticsearchProject>(m => m
.FieldNamesField(a => a .Enabled(false))
);
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"elasticsearchprojects": {
"_field_names": {
"enabled": false
}
}
}
4 changes: 4 additions & 0 deletions src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<None Include="Core\Map\Properties\MultiFieldPropertyWithJustNamePath.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Core\Map\FieldNamesField\FieldNamesFieldTests.cs" />
<Compile Include="Core\MultiPercolate\MultiPercolateTests.cs" />
<Compile Include="Core\Map\Transform\MappingTansformTests.cs" />
<Compile Include="Core\Repository\RestoreTests.cs" />
Expand Down Expand Up @@ -637,6 +638,9 @@
<None Include="Core\Map\MetaField\MetaFieldSerializes.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Core\Map\FieldNamesField\FieldNamesMapping.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Core\Map\Transform\MultipleTransforms.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down