Skip to content

Commit 5842a19

Browse files
committed
Obsolete AllField and IndexField
This commit obsoletes the AllField and IndexField. Both should have been removed in 7.x but were missed. Remove the DataMemberAttribute and add IgnoreDataMemberAttribute so that any value is not sent in a request. Fixes #3905
1 parent e740d1a commit 5842a19

File tree

6 files changed

+113
-28
lines changed

6 files changed

+113
-28
lines changed

src/Nest/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ public IReadOnlyDictionary<Field, IFieldMapping> Deserialize(ref JsonReader read
3737
switch (value)
3838
{
3939
case 0:
40+
#pragma warning disable 618
4041
mapping = formatterResolver.GetFormatter<AllField>()
4142
.Deserialize(ref reader, formatterResolver);
43+
#pragma warning restore 618
4244
break;
4345
case 1:
4446
mapping = formatterResolver.GetFormatter<SourceField>()
@@ -49,8 +51,10 @@ public IReadOnlyDictionary<Field, IFieldMapping> Deserialize(ref JsonReader read
4951
.Deserialize(ref reader, formatterResolver);
5052
break;
5153
case 3:
54+
#pragma warning disable 618
5255
mapping = formatterResolver.GetFormatter<IndexField>()
5356
.Deserialize(ref reader, formatterResolver);
57+
#pragma warning restore 618
5458
break;
5559
case 4:
5660
mapping = formatterResolver.GetFormatter<SizeField>()

src/Nest/Indices/MappingManagement/PutMapping/PutMappingRequest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public partial interface IPutMappingRequest<TDocument> where TDocument : class {
1818
public partial class PutMappingRequest
1919
{
2020
/// <inheritdoc />
21+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
2122
public IAllField AllField { get; set; }
2223

2324
/// <inheritdoc />
@@ -36,6 +37,7 @@ public partial class PutMappingRequest
3637
public IFieldNamesField FieldNamesField { get; set; }
3738

3839
/// <inheritdoc />
40+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
3941
public IIndexField IndexField { get; set; }
4042

4143
/// <inheritdoc />
@@ -63,12 +65,14 @@ public partial class PutMappingRequest<TDocument> where TDocument : class { }
6365
[DataContract]
6466
public partial class PutMappingDescriptor<TDocument> where TDocument : class
6567
{
68+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
6669
IAllField ITypeMapping.AllField { get; set; }
6770
bool? ITypeMapping.DateDetection { get; set; }
6871
Union<bool, DynamicMapping> ITypeMapping.Dynamic { get; set; }
6972
IEnumerable<string> ITypeMapping.DynamicDateFormats { get; set; }
7073
IDynamicTemplateContainer ITypeMapping.DynamicTemplates { get; set; }
7174
IFieldNamesField ITypeMapping.FieldNamesField { get; set; }
75+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
7276
IIndexField ITypeMapping.IndexField { get; set; }
7377
IDictionary<string, object> ITypeMapping.Meta { get; set; }
7478
bool? ITypeMapping.NumericDetection { get; set; }
@@ -102,10 +106,12 @@ public PutMappingDescriptor<TDocument> AutoMap(IPropertyVisitor visitor = null,
102106
public PutMappingDescriptor<TDocument> Dynamic(bool? dynamic = true) => Assign(dynamic, (a, v) => a.Dynamic = v);
103107

104108
/// <inheritdoc cref="ITypeMapping.AllField" />
109+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
105110
public PutMappingDescriptor<TDocument> AllField(Func<AllFieldDescriptor, IAllField> allFieldSelector) =>
106111
Assign(allFieldSelector, (a, v) => a.AllField = v?.Invoke(new AllFieldDescriptor()));
107112

108113
/// <inheritdoc cref="ITypeMapping.IndexField" />
114+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
109115
public PutMappingDescriptor<TDocument> IndexField(Func<IndexFieldDescriptor, IIndexField> indexFieldSelector) =>
110116
Assign(indexFieldSelector, (a, v) => a.IndexField = v?.Invoke(new IndexFieldDescriptor()));
111117

@@ -118,6 +124,7 @@ public PutMappingDescriptor<TDocument> DisableSizeField(bool? disabled = true) =
118124
Assign(disabled, (a, v) => a.SizeField = new SizeField { Enabled = !v });
119125

120126
/// <inheritdoc cref="ITypeMapping.IndexField" />
127+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
121128
public PutMappingDescriptor<TDocument> DisableIndexField(bool? disabled = true) =>
122129
Assign(disabled, (a, v) => a.IndexField = new IndexField { Enabled = !v });
123130

src/Nest/Mapping/Mappings.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Nest
1313
/// new features in the future.
1414
/// </pre>
1515
/// </summary>
16-
[Obsolete("Mappings are no longer type dependant, please use TypeMapping directly")]
16+
[Obsolete("Mappings are no longer type dependent, please use TypeMapping directly")]
1717
public class Mappings : ObsoleteMappingsBase, ITypeMapping, IEnumerable<ITypeMapping>
1818
{
1919
private IEnumerable<ITypeMapping> AsEnumerable => new[] { new TypeMapping() };
@@ -29,7 +29,8 @@ public class Mappings : ObsoleteMappingsBase, ITypeMapping, IEnumerable<ITypeMap
2929

3030
public abstract class ObsoleteMappingsBase : ITypeMapping
3131
{
32-
[DataMember(Name = "_all")]
32+
[IgnoreDataMember]
33+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
3334
public IAllField AllField { get => Wrapped.AllField; set => Wrapped.AllField = value; }
3435
[DataMember(Name = "date_detection")]
3536
bool? ITypeMapping.DateDetection { get => Wrapped.DateDetection; set => Wrapped.DateDetection = value; }
@@ -41,7 +42,8 @@ public abstract class ObsoleteMappingsBase : ITypeMapping
4142
IDynamicTemplateContainer ITypeMapping.DynamicTemplates { get => Wrapped.DynamicTemplates; set => Wrapped.DynamicTemplates = value; }
4243
[DataMember(Name = "_field_names")]
4344
IFieldNamesField ITypeMapping.FieldNamesField { get => Wrapped.FieldNamesField; set => Wrapped.FieldNamesField = value; }
44-
[DataMember(Name = "_index")]
45+
[IgnoreDataMember]
46+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
4547
IIndexField ITypeMapping.IndexField { get => Wrapped.IndexField; set => Wrapped.IndexField = value; }
4648
[DataMember(Name = "_meta")]
4749
IDictionary<string, object> ITypeMapping.Meta { get => Wrapped.Meta; set => Wrapped.Meta = value; }

src/Nest/Mapping/MetaFields/All/AllField.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.Runtime.Serialization;
1+
using System;
2+
using System.Runtime.Serialization;
23

34
namespace Nest
45
{
6+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
57
[ReadAs(typeof(AllField))]
68
public interface IAllField : IFieldMapping
79
{
@@ -36,6 +38,7 @@ public interface IAllField : IFieldMapping
3638
bool? StoreTermVectors { get; set; }
3739
}
3840

41+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
3942
public class AllField : IAllField
4043
{
4144
public string Analyzer { get; set; }
@@ -50,7 +53,7 @@ public class AllField : IAllField
5053
public bool? StoreTermVectors { get; set; }
5154
}
5255

53-
//OBSOLETE
56+
[Obsolete("The _all field is no longer supported in Elasticsearch 7.x and will be removed in the next major release. The value will not be sent in a request. An _all like field can be achieved using copy_to")]
5457
public class AllFieldDescriptor
5558
: DescriptorBase<AllFieldDescriptor, IAllField>, IAllField
5659
{

src/Nest/Mapping/MetaFields/Index/IndexField.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
using System.Runtime.Serialization;
1+
using System;
2+
using System.Runtime.Serialization;
23

34
namespace Nest
45
{
6+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
57
[ReadAs(typeof(IndexField))]
68
public interface IIndexField : IFieldMapping
79
{
810
[DataMember(Name ="enabled")]
911
bool? Enabled { get; set; }
1012
}
1113

14+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
1215
public class IndexField : IIndexField
1316
{
1417
public bool? Enabled { get; set; }
1518
}
1619

20+
[Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")]
1721
public class IndexFieldDescriptor
1822
: DescriptorBase<IndexFieldDescriptor, IIndexField>, IIndexField
1923
{

0 commit comments

Comments
 (0)