Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public GeoPointAttribute() : base(FieldType.GeoPoint) { }

bool? IGeoPointProperty.IgnoreMalformed { get; set; }

public bool IgnoreMalformed { get { return Self.IgnoreMalformed.GetValueOrDefault(); } set { Self.IgnoreMalformed = value; } }
bool? IGeoPointProperty.IgnoreZValue { get; set; }
GeoLocation IGeoPointProperty.NullValue { get; set; }

public bool IgnoreMalformed { get => Self.IgnoreMalformed.GetValueOrDefault(); set => Self.IgnoreMalformed = value; }
public bool IgnoreZValue { get => Self.IgnoreZValue.GetValueOrDefault(); set => Self.IgnoreZValue= value; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be Self.IgnoreZValue.GetValueOrDefault(true), in line with the default value in Elasticsearch

}
}
38 changes: 38 additions & 0 deletions src/Nest/Mapping/Types/Geo/GeoPoint/GeoPointProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,45 @@ namespace Nest
[JsonObject(MemberSerialization.OptIn)]
public interface IGeoPointProperty : IDocValuesProperty
{
/// <summary>
/// If true, malformed geo-points are ignored. If false (default), malformed
/// geo-points throw an exception and reject the whole document.
/// </summary>
[JsonProperty("ignore_malformed")]
bool? IgnoreMalformed { get; set; }


/// <summary>
/// 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.
/// </summary>
[JsonProperty("ignore_z_value")]
bool? IgnoreZValue { get; set; }

/// <summary>
/// Accepts an geopoint value which is substituted for any explicit null values.
/// Defaults to null, which means the field is treated as missing.
/// </summary>
[JsonProperty("null_value")]
GeoLocation NullValue { get; set; }

}

[DebuggerDisplay("{DebugDisplay}")]
public class GeoPointProperty : DocValuesPropertyBase, IGeoPointProperty
{
public GeoPointProperty() : base(FieldType.GeoPoint) { }

/// <inheritdoc />
public bool? IgnoreMalformed { get; set; }

/// <inheritdoc />
public bool? IgnoreZValue { get; set; }

/// <inheritdoc />
public GeoLocation NullValue { get; set; }
}

[DebuggerDisplay("{DebugDisplay}")]
Expand All @@ -25,9 +54,18 @@ public class GeoPointPropertyDescriptor<T>
where T : class
{
bool? IGeoPointProperty.IgnoreMalformed { get; set; }
bool? IGeoPointProperty.IgnoreZValue { get; set; }
GeoLocation IGeoPointProperty.NullValue { get; set; }

public GeoPointPropertyDescriptor() : base(FieldType.GeoPoint) { }

/// <inheritdoc cref="IGeoPointProperty.IgnoreMalformed" />
public GeoPointPropertyDescriptor<T> IgnoreMalformed(bool? ignoreMalformed = true) => Assign(a => a.IgnoreMalformed = ignoreMalformed);

/// <inheritdoc cref="IGeoPointProperty.IgnoreZValue" />
public GeoPointPropertyDescriptor<T> IgnoreZValue(bool? ignoreZValue = true) => Assign(a => a.IgnoreZValue = ignoreZValue);

/// <inheritdoc cref="IGeoPointProperty.NullValue" />
public GeoPointPropertyDescriptor<T> NullValue(GeoLocation defaultValue) => Assign(a => a.NullValue = defaultValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -24,7 +23,8 @@ public class GeoPointAttributeTests : AttributeTestsBase<GeoPointTest>
full = new
{
type = "geo_point",
ignore_malformed = true
ignore_malformed = true,
ignore_z_value = true
},
minimal = new
{
Expand Down