diff --git a/src/Nest/Mapping/MetaFields/IFieldMapping.cs b/src/Nest/Mapping/MetaFields/IFieldMapping.cs index c7d38273c8e..01e3abe6910 100644 --- a/src/Nest/Mapping/MetaFields/IFieldMapping.cs +++ b/src/Nest/Mapping/MetaFields/IFieldMapping.cs @@ -1,4 +1,7 @@ namespace Nest { + /// + /// A document field mapping in Elasticsearch + /// public interface IFieldMapping { } } diff --git a/src/Nest/Mapping/Types/CorePropertyBase.cs b/src/Nest/Mapping/Types/CorePropertyBase.cs index 370eef9bedf..d162f8ec30b 100644 --- a/src/Nest/Mapping/Types/CorePropertyBase.cs +++ b/src/Nest/Mapping/Types/CorePropertyBase.cs @@ -4,6 +4,9 @@ namespace Nest { + /// + /// Core properties of a mapping for a property type to a document field in Elasticsearch + /// [JsonObject(MemberSerialization.OptIn)] [ContractJsonConverter(typeof(PropertyJsonConverter))] public interface ICoreProperty : IProperty @@ -20,13 +23,14 @@ public interface ICoreProperty : IProperty /// /// Configures multi-fields for this field. Allows one field to be indexed in different - /// ways to serve different purposes + /// ways to serve different search and analytics purposes /// [JsonProperty("fields", DefaultValueHandling = DefaultValueHandling.Ignore)] IProperties Fields { get; set; } /// - /// Which relevancy scoring algorithm or similarity should be used. Defaults to BM25 + /// Which relevancy scoring algorithm or similarity should be used. + /// Defaults to /// [JsonProperty("similarity")] Union Similarity { get; set; } @@ -40,6 +44,7 @@ public interface ICoreProperty : IProperty Fields CopyTo { get; set; } } + /// [DebuggerDisplay("{DebugDisplay}")] public abstract class CorePropertyBase : PropertyBase, ICoreProperty { diff --git a/src/Nest/Mapping/Types/CorePropertyDescriptorBase.cs b/src/Nest/Mapping/Types/CorePropertyDescriptorBase.cs index 4d540e8d6a2..8b2ab54a778 100644 --- a/src/Nest/Mapping/Types/CorePropertyDescriptorBase.cs +++ b/src/Nest/Mapping/Types/CorePropertyDescriptorBase.cs @@ -3,6 +3,7 @@ namespace Nest { + /// public abstract class CorePropertyDescriptorBase : PropertyDescriptorBase, ICoreProperty where TDescriptor : CorePropertyDescriptorBase, TInterface @@ -16,14 +17,19 @@ public abstract class CorePropertyDescriptorBase protected CorePropertyDescriptorBase(FieldType type) : base(type) {} + /// public TDescriptor Store(bool? store = true) => Assign(a => a.Store = store); + /// public TDescriptor Fields(Func, IPromise> selector) => Assign(a => a.Fields = selector?.Invoke(new PropertiesDescriptor())?.Value); + /// public TDescriptor Similarity(SimilarityOption? similarity) => Assign(a => a.Similarity = similarity); + /// public TDescriptor Similarity(string similarity) => Assign(a => a.Similarity = similarity); + /// public TDescriptor CopyTo(Func, IPromise> fields) => Assign(a => a.CopyTo = fields?.Invoke(new FieldsDescriptor())?.Value); } } diff --git a/src/Nest/Mapping/Types/DocValuesPropertyBase.cs b/src/Nest/Mapping/Types/DocValuesPropertyBase.cs index e6a74a18c1b..d912c6afe4f 100644 --- a/src/Nest/Mapping/Types/DocValuesPropertyBase.cs +++ b/src/Nest/Mapping/Types/DocValuesPropertyBase.cs @@ -4,18 +4,27 @@ namespace Nest { + /// + /// Properties of a mapping for a property type to a document field that has doc_values in Elasticsearch + /// [JsonObject(MemberSerialization.OptIn)] [ContractJsonConverter(typeof(PropertyJsonConverter))] public interface IDocValuesProperty : ICoreProperty { + /// + /// Whether to persist the value at index time in a columnar data structure (referred to as doc_values in Lucene) + /// which makes the value available for efficient sorting and aggregations. Default is true. + /// [JsonProperty("doc_values")] bool? DocValues { get; set; } } + /// public abstract class DocValuesPropertyBase : CorePropertyBase, IDocValuesProperty { protected DocValuesPropertyBase(FieldType type) : base(type) { } + /// public bool? DocValues { get; set; } } } diff --git a/src/Nest/Mapping/Types/DocValuesPropertyDescriptorBase.cs b/src/Nest/Mapping/Types/DocValuesPropertyDescriptorBase.cs index 860f42bedd6..a544cf99e8a 100644 --- a/src/Nest/Mapping/Types/DocValuesPropertyDescriptorBase.cs +++ b/src/Nest/Mapping/Types/DocValuesPropertyDescriptorBase.cs @@ -3,6 +3,7 @@ namespace Nest { + /// public abstract class DocValuesPropertyDescriptorBase : CorePropertyDescriptorBase, IDocValuesProperty where TDescriptor : DocValuesPropertyDescriptorBase, TInterface @@ -13,6 +14,7 @@ public abstract class DocValuesPropertyDescriptorBase public TDescriptor DocValues(bool? docValues = true) => Assign(a => a.DocValues = docValues); } } diff --git a/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointAttribute.cs b/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointAttribute.cs index ec9d0de7e3d..91013098fb0 100644 --- a/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointAttribute.cs +++ b/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointAttribute.cs @@ -7,7 +7,13 @@ public class GeoPointAttribute : ElasticsearchDocValuesPropertyAttributeBase, IG public GeoPointAttribute() : base(FieldType.GeoPoint) { } bool? IGeoPointProperty.IgnoreMalformed { get; set; } + bool? IGeoPointProperty.IgnoreZValue { get; set; } + GeoLocation IGeoPointProperty.NullValue { get; set; } - public bool IgnoreMalformed { get { return Self.IgnoreMalformed.GetValueOrDefault(); } set { Self.IgnoreMalformed = value; } } + /// + public bool IgnoreMalformed { get => Self.IgnoreMalformed.GetValueOrDefault(); set => Self.IgnoreMalformed = value; } + + /// + public bool IgnoreZValue { get => Self.IgnoreZValue.GetValueOrDefault(true); set => Self.IgnoreZValue= value; } } } diff --git a/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointProperty.cs b/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointProperty.cs index af1e05b7820..1cf243faf49 100644 --- a/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointProperty.cs +++ b/src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointProperty.cs @@ -4,11 +4,35 @@ namespace Nest { + /// + /// Data type mapping to map a property as a geopoint + /// [JsonObject(MemberSerialization.OptIn)] public interface IGeoPointProperty : IDocValuesProperty { + /// + /// If true, malformed geo-points are ignored. If false (default), malformed + /// geo-points throw an exception and reject the whole document. + /// [JsonProperty("ignore_malformed")] bool? IgnoreMalformed { get; set; } + + + /// + /// If true (default) three dimension points will be accepted (stored in source) but only + /// latitude and longitude values will be indexed; the third dimension is ignored. If false, geo-points + /// containing any more than latitude and longitude (two dimensions) values + /// throw an exception and reject the whole document. + /// + [JsonProperty("ignore_z_value")] + bool? IgnoreZValue { get; set; } + + /// + /// Accepts a geo_point value which is substituted for any explicit null values. + /// Defaults to null, which means the field is treated as missing. + /// + [JsonProperty("null_value")] + GeoLocation NullValue { get; set; } } [DebuggerDisplay("{DebugDisplay}")] @@ -16,7 +40,14 @@ public class GeoPointProperty : DocValuesPropertyBase, IGeoPointProperty { public GeoPointProperty() : base(FieldType.GeoPoint) { } + /// public bool? IgnoreMalformed { get; set; } + + /// + public bool? IgnoreZValue { get; set; } + + /// + public GeoLocation NullValue { get; set; } } [DebuggerDisplay("{DebugDisplay}")] @@ -25,9 +56,18 @@ public class GeoPointPropertyDescriptor where T : class { bool? IGeoPointProperty.IgnoreMalformed { get; set; } + bool? IGeoPointProperty.IgnoreZValue { get; set; } + GeoLocation IGeoPointProperty.NullValue { get; set; } public GeoPointPropertyDescriptor() : base(FieldType.GeoPoint) { } + /// public GeoPointPropertyDescriptor IgnoreMalformed(bool? ignoreMalformed = true) => Assign(a => a.IgnoreMalformed = ignoreMalformed); + + /// + public GeoPointPropertyDescriptor IgnoreZValue(bool? ignoreZValue = true) => Assign(a => a.IgnoreZValue = ignoreZValue); + + /// + public GeoPointPropertyDescriptor NullValue(GeoLocation defaultValue) => Assign(a => a.NullValue = defaultValue); } } diff --git a/src/Nest/Mapping/Types/Properties.cs b/src/Nest/Mapping/Types/Properties.cs index 4cd602cb256..e6ac94cbc95 100644 --- a/src/Nest/Mapping/Types/Properties.cs +++ b/src/Nest/Mapping/Types/Properties.cs @@ -49,7 +49,7 @@ public partial interface IPropertiesDescriptor TReturnType Text(Func, ITextProperty> selector); TReturnType Keyword(Func, IKeywordProperty> selector); /// - /// Number introduces a numeric mapping that defaults to `float` use .Type() to set the right type if needed or use + /// Number introduces a numeric mapping that defaults to `float`. Use .Type() to set the right type if needed or use /// Scalar instead of /// TReturnType Number(Func, INumberProperty> selector); diff --git a/src/Nest/Mapping/Types/PropertyBase.cs b/src/Nest/Mapping/Types/PropertyBase.cs index 9f14323818f..30a10e5c885 100644 --- a/src/Nest/Mapping/Types/PropertyBase.cs +++ b/src/Nest/Mapping/Types/PropertyBase.cs @@ -7,6 +7,9 @@ namespace Nest { + /// + /// A mapping for a property type to a document field in Elasticsearch + /// [JsonObject(MemberSerialization.OptIn)] [ContractJsonConverter(typeof(PropertyJsonConverter))] public interface IProperty : IFieldMapping @@ -29,25 +32,32 @@ public interface IProperty : IFieldMapping IDictionary LocalMetadata { get; set; } } + /// + /// A mapping for a property from a CLR type + /// public interface IPropertyWithClrOrigin { + /// + /// The CLR property to which the mapping relates + /// PropertyInfo ClrOrigin { get; set; } } + /// [DebuggerDisplay("{DebugDisplay}")] public abstract class PropertyBase : IProperty, IPropertyWithClrOrigin { private string _type; - protected string TypeOverride { get => _type; set => _type = value; } string IProperty.Type { get => _type; set => _type = value; } - PropertyInfo IPropertyWithClrOrigin.ClrOrigin { get; set; } - protected PropertyBase(FieldType type) - { - ((IProperty)this).Type = type.GetStringValue(); - } + protected PropertyBase(FieldType type) => ((IProperty)this).Type = type.GetStringValue(); + + /// + /// Override for the property type, used for custom mappings + /// + protected string TypeOverride { get => _type; set => _type = value; } protected string DebugDisplay => $"Type: {((IProperty)this).Type ?? ""}, Name: {Name.DebugDisplay} "; diff --git a/src/Nest/Mapping/Types/PropertyDescriptorBase.cs b/src/Nest/Mapping/Types/PropertyDescriptorBase.cs index 6d4caab78dd..453f89efaf9 100644 --- a/src/Nest/Mapping/Types/PropertyDescriptorBase.cs +++ b/src/Nest/Mapping/Types/PropertyDescriptorBase.cs @@ -5,6 +5,7 @@ namespace Nest { + /// public abstract class PropertyDescriptorBase : DescriptorBase, IProperty where TDescriptor : PropertyDescriptorBase, TInterface @@ -21,13 +22,13 @@ public abstract class PropertyDescriptorBase protected PropertyDescriptorBase(FieldType type) { Self.Type = type.GetStringValue(); } + /// public TDescriptor Name(PropertyName name) => Assign(a => a.Name = name); + /// public TDescriptor Name(Expression> objectPath) => Assign(a => a.Name = objectPath); - /// - /// Local property metadata that will NOT be stored in Elasticsearch with the mappings - /// + /// public TDescriptor LocalMetadata(Func, FluentDictionary> selector) => Assign(a => a.LocalMetadata = selector?.Invoke(new FluentDictionary())); } diff --git a/src/Tests/Tests/Mapping/Types/Geo/GeoPoint/GeoPointAttributeTests.cs b/src/Tests/Tests/Mapping/Types/Geo/GeoPoint/GeoPointAttributeTests.cs index e480fd8211c..9c60d7790a9 100644 --- a/src/Tests/Tests/Mapping/Types/Geo/GeoPoint/GeoPointAttributeTests.cs +++ b/src/Tests/Tests/Mapping/Types/Geo/GeoPoint/GeoPointAttributeTests.cs @@ -5,8 +5,7 @@ namespace Tests.Mapping.Types.Geo.GeoPoint { public class GeoPointTest { - [GeoPoint( - IgnoreMalformed = true)] + [GeoPoint(IgnoreMalformed = true, IgnoreZValue = true)] public string Full { get; set; } [GeoPoint] @@ -24,7 +23,8 @@ public class GeoPointAttributeTests : AttributeTestsBase full = new { type = "geo_point", - ignore_malformed = true + ignore_malformed = true, + ignore_z_value = true }, minimal = new {