diff --git a/src/Nest/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs b/src/Nest/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs index f6a6d4ae766..157684b1e97 100644 --- a/src/Nest/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs +++ b/src/Nest/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs @@ -37,8 +37,10 @@ public IReadOnlyDictionary Deserialize(ref JsonReader read switch (value) { case 0: +#pragma warning disable 618 mapping = formatterResolver.GetFormatter() .Deserialize(ref reader, formatterResolver); +#pragma warning restore 618 break; case 1: mapping = formatterResolver.GetFormatter() @@ -49,8 +51,10 @@ public IReadOnlyDictionary Deserialize(ref JsonReader read .Deserialize(ref reader, formatterResolver); break; case 3: +#pragma warning disable 618 mapping = formatterResolver.GetFormatter() .Deserialize(ref reader, formatterResolver); +#pragma warning restore 618 break; case 4: mapping = formatterResolver.GetFormatter() diff --git a/src/Nest/Indices/MappingManagement/PutMapping/PutMappingRequest.cs b/src/Nest/Indices/MappingManagement/PutMapping/PutMappingRequest.cs index 89c0356a9e0..8f245e6b4ea 100644 --- a/src/Nest/Indices/MappingManagement/PutMapping/PutMappingRequest.cs +++ b/src/Nest/Indices/MappingManagement/PutMapping/PutMappingRequest.cs @@ -18,6 +18,7 @@ public partial interface IPutMappingRequest where TDocument : class { public partial class PutMappingRequest { /// + [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")] public IAllField AllField { get; set; } /// @@ -36,6 +37,7 @@ public partial class PutMappingRequest public IFieldNamesField FieldNamesField { get; set; } /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public IIndexField IndexField { get; set; } /// @@ -63,12 +65,14 @@ public partial class PutMappingRequest where TDocument : class { } [DataContract] public partial class PutMappingDescriptor where TDocument : class { + [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")] IAllField ITypeMapping.AllField { get; set; } bool? ITypeMapping.DateDetection { get; set; } Union ITypeMapping.Dynamic { get; set; } IEnumerable ITypeMapping.DynamicDateFormats { get; set; } IDynamicTemplateContainer ITypeMapping.DynamicTemplates { get; set; } IFieldNamesField ITypeMapping.FieldNamesField { get; set; } + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] IIndexField ITypeMapping.IndexField { get; set; } IDictionary ITypeMapping.Meta { get; set; } bool? ITypeMapping.NumericDetection { get; set; } @@ -102,10 +106,12 @@ public PutMappingDescriptor AutoMap(IPropertyVisitor visitor = null, public PutMappingDescriptor Dynamic(bool? dynamic = true) => Assign(dynamic, (a, v) => a.Dynamic = v); /// + [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")] public PutMappingDescriptor AllField(Func allFieldSelector) => Assign(allFieldSelector, (a, v) => a.AllField = v?.Invoke(new AllFieldDescriptor())); /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public PutMappingDescriptor IndexField(Func indexFieldSelector) => Assign(indexFieldSelector, (a, v) => a.IndexField = v?.Invoke(new IndexFieldDescriptor())); @@ -118,6 +124,7 @@ public PutMappingDescriptor DisableSizeField(bool? disabled = true) = Assign(disabled, (a, v) => a.SizeField = new SizeField { Enabled = !v }); /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public PutMappingDescriptor DisableIndexField(bool? disabled = true) => Assign(disabled, (a, v) => a.IndexField = new IndexField { Enabled = !v }); diff --git a/src/Nest/Mapping/Mappings.cs b/src/Nest/Mapping/Mappings.cs index 920f42a156f..9a3ac504203 100644 --- a/src/Nest/Mapping/Mappings.cs +++ b/src/Nest/Mapping/Mappings.cs @@ -13,7 +13,7 @@ namespace Nest /// new features in the future. /// /// - [Obsolete("Mappings are no longer type dependant, please use TypeMapping directly")] + [Obsolete("Mappings are no longer type dependent, please use TypeMapping directly")] public class Mappings : ObsoleteMappingsBase, ITypeMapping, IEnumerable { private IEnumerable AsEnumerable => new[] { new TypeMapping() }; @@ -29,7 +29,8 @@ public class Mappings : ObsoleteMappingsBase, ITypeMapping, IEnumerable Wrapped.AllField; set => Wrapped.AllField = value; } [DataMember(Name = "date_detection")] bool? ITypeMapping.DateDetection { get => Wrapped.DateDetection; set => Wrapped.DateDetection = value; } @@ -41,7 +42,8 @@ public abstract class ObsoleteMappingsBase : ITypeMapping IDynamicTemplateContainer ITypeMapping.DynamicTemplates { get => Wrapped.DynamicTemplates; set => Wrapped.DynamicTemplates = value; } [DataMember(Name = "_field_names")] IFieldNamesField ITypeMapping.FieldNamesField { get => Wrapped.FieldNamesField; set => Wrapped.FieldNamesField = value; } - [DataMember(Name = "_index")] + [IgnoreDataMember] + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] IIndexField ITypeMapping.IndexField { get => Wrapped.IndexField; set => Wrapped.IndexField = value; } [DataMember(Name = "_meta")] IDictionary ITypeMapping.Meta { get => Wrapped.Meta; set => Wrapped.Meta = value; } diff --git a/src/Nest/Mapping/MetaFields/All/AllField.cs b/src/Nest/Mapping/MetaFields/All/AllField.cs index 7d2eaf0e9d3..58f33e6235e 100644 --- a/src/Nest/Mapping/MetaFields/All/AllField.cs +++ b/src/Nest/Mapping/MetaFields/All/AllField.cs @@ -1,7 +1,9 @@ -using System.Runtime.Serialization; +using System; +using System.Runtime.Serialization; namespace Nest { + [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")] [ReadAs(typeof(AllField))] public interface IAllField : IFieldMapping { @@ -36,6 +38,7 @@ public interface IAllField : IFieldMapping bool? StoreTermVectors { get; set; } } + [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")] public class AllField : IAllField { public string Analyzer { get; set; } @@ -50,7 +53,7 @@ public class AllField : IAllField public bool? StoreTermVectors { get; set; } } - //OBSOLETE + [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")] public class AllFieldDescriptor : DescriptorBase, IAllField { diff --git a/src/Nest/Mapping/MetaFields/Index/IndexField.cs b/src/Nest/Mapping/MetaFields/Index/IndexField.cs index 64f9504b699..e9b1bd82001 100644 --- a/src/Nest/Mapping/MetaFields/Index/IndexField.cs +++ b/src/Nest/Mapping/MetaFields/Index/IndexField.cs @@ -1,7 +1,9 @@ -using System.Runtime.Serialization; +using System; +using System.Runtime.Serialization; namespace Nest { + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] [ReadAs(typeof(IndexField))] public interface IIndexField : IFieldMapping { @@ -9,11 +11,13 @@ public interface IIndexField : IFieldMapping bool? Enabled { get; set; } } + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public class IndexField : IIndexField { public bool? Enabled { get; set; } } + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public class IndexFieldDescriptor : DescriptorBase, IIndexField { diff --git a/src/Nest/Mapping/TypeMapping.cs b/src/Nest/Mapping/TypeMapping.cs index 428504cac2c..b6770de7225 100644 --- a/src/Nest/Mapping/TypeMapping.cs +++ b/src/Nest/Mapping/TypeMapping.cs @@ -9,43 +9,98 @@ namespace Nest [ReadAs(typeof(TypeMapping))] public interface ITypeMapping { - [DataMember(Name = "_all")] + [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")] + [IgnoreDataMember] IAllField AllField { get; set; } + /// + /// If enabled (default), then new string fields are checked to see whether their contents match + /// any of the date patterns specified in . + /// If a match is found, a new date field is added with the corresponding format. + /// [DataMember(Name = "date_detection")] bool? DateDetection { get; set; } + /// + /// Whether new unseen fields will be added to the mapping. Default is true. + /// A value of false will ignore unknown fields and a value of + /// will result in an error if an unknown field is encountered in a document. + /// [DataMember(Name = "dynamic")] Union Dynamic { get; set; } + /// + /// Date formats used by + /// [DataMember(Name = "dynamic_date_formats")] IEnumerable DynamicDateFormats { get; set; } + /// + /// Dynamic templates allow you to define custom mappings that can be applied to dynamically added fields based on + /// - the datatype detected by Elasticsearch, with . + /// - the name of the field, with and or + /// . + /// - the full dotted path to the field, with and + /// . + /// The original field name {name} and the detected datatype {dynamic_type} template variables can be + /// used in the mapping specification as placeholders. + /// [DataMember(Name = "dynamic_templates")] IDynamicTemplateContainer DynamicTemplates { get; set; } + /// + /// Used to index the names of every field in a document that contains any value other than null. + /// This field was used by the exists query to find documents that either have or don’t have any non-null value for a particular field. + /// Now, it only indexes the names of fields that have doc_values and norms disabled. + /// Can be disabled. Disabling _field_names is often not necessary because it no longer carries the index overhead it once did. + /// If you have a lot of fields which have doc_values and norms disabled and you do not need to execute exists queries + /// using those fields you might want to disable + /// [DataMember(Name = "_field_names")] IFieldNamesField FieldNamesField { get; set; } - [DataMember(Name = "_index")] + + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] + [IgnoreDataMember] IIndexField IndexField { get; set; } + /// + /// Custom meta data to associate with a mapping. Not used by Elasticsearch, + /// but can be used to store application-specific metadata. + /// [DataMember(Name = "_meta")] [JsonFormatter(typeof(VerbatimDictionaryInterfaceKeysFormatter))] IDictionary Meta { get; set; } + /// + /// If enabled (not enabled by default), then new string fields are checked to see whether + /// they wholly contain a numeric value and if so, to map as a numeric field. + /// [DataMember(Name = "numeric_detection")] bool? NumericDetection { get; set; } + /// + /// Specifies the mapping properties + /// [DataMember(Name = "properties")] IProperties Properties { get; set; } + /// + /// Specifies configuration for the _routing parameter + /// [DataMember(Name = "_routing")] IRoutingField RoutingField { get; set; } + /// + /// If enabled, indexes the size in bytes of the original _source field. + /// Requires mapper-size plugin be installed + /// [DataMember(Name = "_size")] ISizeField SizeField { get; set; } + /// + /// Specifies configuration for the _source field + /// [DataMember(Name = "_source")] ISourceField SourceField { get; set; } } @@ -53,6 +108,7 @@ public interface ITypeMapping public class TypeMapping : ITypeMapping { /// + [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")] public IAllField AllField { get; set; } /// @@ -71,6 +127,7 @@ public class TypeMapping : ITypeMapping public IFieldNamesField FieldNamesField { get; set; } /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public IIndexField IndexField { get; set; } /// @@ -96,12 +153,14 @@ public class TypeMapping : ITypeMapping public class TypeMappingDescriptor : DescriptorBase, ITypeMapping>, ITypeMapping where T : class { + [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")] IAllField ITypeMapping.AllField { get; set; } bool? ITypeMapping.DateDetection { get; set; } Union ITypeMapping.Dynamic { get; set; } IEnumerable ITypeMapping.DynamicDateFormats { get; set; } IDynamicTemplateContainer ITypeMapping.DynamicTemplates { get; set; } IFieldNamesField ITypeMapping.FieldNamesField { get; set; } + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] IIndexField ITypeMapping.IndexField { get; set; } IDictionary ITypeMapping.Meta { get; set; } bool? ITypeMapping.NumericDetection { get; set; } @@ -112,7 +171,7 @@ public class TypeMappingDescriptor : DescriptorBase, /// /// Convenience method to map as much as it can based on attributes set on the - /// type. + /// type, as well as inferring mappings from the CLR property types. ///
This method also automatically sets up mappings for known values types (int, long, double, datetime, etc)
///
Class types default to object and Enums to int
///
Later calls can override whatever is set is by this call.
@@ -122,7 +181,7 @@ public TypeMappingDescriptor AutoMap(IPropertyVisitor visitor = null, int max /// /// Convenience method to map as much as it can based on attributes set on the - /// type. + /// type, as well as inferring mappings from the CLR property types. /// This particular overload is useful for automapping any children ///
This method also automatically sets up mappings for known values types (int, long, double, datetime, etc)
///
Class types default to object and Enums to int
@@ -136,7 +195,7 @@ public TypeMappingDescriptor AutoMap(Type documentType, IPropertyVisitor visi /// /// Convenience method to map as much as it can based on attributes set on the - /// type. + /// type, as well as inferring mappings from the CLR property types. /// This particular overload is useful for automapping any children ///
This method also automatically sets up mappings for known values types (int, long, double, datetime, etc)
///
Class types default to object and Enums to int
@@ -146,70 +205,76 @@ public TypeMappingDescriptor AutoMap(IPropertyVisitor visitor = nu where TDocument : class => Assign(Self.Properties.AutoMap(visitor, maxRecursion), (a, v) => a.Properties = v); - /// + /// + /// Convenience method to map as much as it can based on attributes set on the + /// type, as well as inferring mappings from the CLR property types. + /// This overload determines how deep automapping should recurse on a complex CLR type. + /// public TypeMappingDescriptor AutoMap(int maxRecursion) => AutoMap(null, maxRecursion); - /// + /// public TypeMappingDescriptor Dynamic(Union dynamic) => Assign(dynamic, (a, v) => a.Dynamic = v); - /// + /// public TypeMappingDescriptor Dynamic(bool dynamic = true) => Assign(dynamic, (a, v) => a.Dynamic = v); - /// + [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")] public TypeMappingDescriptor AllField(Func allFieldSelector) => Assign(allFieldSelector, (a, v) => a.AllField = v?.Invoke(new AllFieldDescriptor())); - /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public TypeMappingDescriptor IndexField(Func indexFieldSelector) => Assign(indexFieldSelector, (a, v) => a.IndexField = v?.Invoke(new IndexFieldDescriptor())); - /// + /// public TypeMappingDescriptor SizeField(Func sizeFieldSelector) => Assign(sizeFieldSelector, (a, v) => a.SizeField = v?.Invoke(new SizeFieldDescriptor())); - /// + /// public TypeMappingDescriptor SourceField(Func sourceFieldSelector) => Assign(sourceFieldSelector, (a, v) => a.SourceField = v?.Invoke(new SourceFieldDescriptor())); - /// + /// public TypeMappingDescriptor DisableSizeField(bool? disabled = true) => Assign(new SizeField { Enabled = !disabled }, (a, v) => a.SizeField = v); - /// + [Obsolete("Configuration for the _index field is no longer supported in Elasticsearch 7.x and will be removed in the next major release.")] public TypeMappingDescriptor DisableIndexField(bool? disabled = true) => Assign(new IndexField { Enabled = !disabled }, (a, v) => a.IndexField = v); - /// + /// public TypeMappingDescriptor DynamicDateFormats(IEnumerable dateFormats) => Assign(dateFormats, (a, v) => a.DynamicDateFormats = v); - /// + /// public TypeMappingDescriptor DateDetection(bool? detect = true) => Assign(detect, (a, v) => a.DateDetection = v); - /// + /// public TypeMappingDescriptor NumericDetection(bool? detect = true) => Assign(detect, (a, v) => a.NumericDetection = v); - /// + /// public TypeMappingDescriptor RoutingField(Func, IRoutingField> routingFieldSelector) => Assign(routingFieldSelector, (a, v) => a.RoutingField = v?.Invoke(new RoutingFieldDescriptor())); - /// + /// public TypeMappingDescriptor FieldNamesField(Func, IFieldNamesField> fieldNamesFieldSelector) => Assign(fieldNamesFieldSelector.Invoke(new FieldNamesFieldDescriptor()), (a, v) => a.FieldNamesField = v); - /// + /// public TypeMappingDescriptor Meta(Func, FluentDictionary> metaSelector) => Assign(metaSelector(new FluentDictionary()), (a, v) => a.Meta = v); - /// + /// public TypeMappingDescriptor Meta(Dictionary metaDictionary) => Assign(metaDictionary, (a, v) => a.Meta = v); + /// public TypeMappingDescriptor Properties(Func, IPromise> propertiesSelector) => Assign(propertiesSelector, (a, v) => a.Properties = v?.Invoke(new PropertiesDescriptor(Self.Properties))?.Value); + /// public TypeMappingDescriptor Properties(Func, IPromise> propertiesSelector) where TDocument : class => Assign(propertiesSelector, (a, v) => a.Properties = v?.Invoke(new PropertiesDescriptor(Self.Properties))?.Value); - /// + /// public TypeMappingDescriptor DynamicTemplates( Func, IPromise> dynamicTemplatesSelector ) =>