Skip to content

Add missing datatype members to IPropertiesDescriptor #4366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2020
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
48 changes: 44 additions & 4 deletions src/Nest/Mapping/DynamicTemplate/SingleMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,95 @@ namespace Nest
{
public class SingleMappingSelector<T> : SelectorBase, IPropertiesDescriptor<T, IProperty> where T : class
{
/// <inheritdoc />
public IProperty Binary(Func<BinaryPropertyDescriptor<T>, IBinaryProperty> selector) =>
selector?.Invoke(new BinaryPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Boolean(Func<BooleanPropertyDescriptor<T>, IBooleanProperty> selector) =>
selector?.Invoke(new BooleanPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Completion(Func<CompletionPropertyDescriptor<T>, ICompletionProperty> selector) =>
selector?.Invoke(new CompletionPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Date(Func<DatePropertyDescriptor<T>, IDateProperty> selector) =>
selector?.Invoke(new DatePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty DateNanos(Func<DateNanosPropertyDescriptor<T>, IDateNanosProperty> selector) =>
selector?.Invoke(new DateNanosPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty DateRange(Func<DateRangePropertyDescriptor<T>, IDateRangeProperty> selector) =>
selector?.Invoke(new DateRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty DoubleRange(Func<DoubleRangePropertyDescriptor<T>, IDoubleRangeProperty> selector) =>
selector?.Invoke(new DoubleRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty FloatRange(Func<FloatRangePropertyDescriptor<T>, IFloatRangeProperty> selector) =>
selector?.Invoke(new FloatRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty GeoPoint(Func<GeoPointPropertyDescriptor<T>, IGeoPointProperty> selector) =>
selector?.Invoke(new GeoPointPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty GeoShape(Func<GeoShapePropertyDescriptor<T>, IGeoShapeProperty> selector) =>
selector?.Invoke(new GeoShapePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Shape(Func<ShapePropertyDescriptor<T>, IShapeProperty> selector) =>
selector?.Invoke(new ShapePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty IntegerRange(Func<IntegerRangePropertyDescriptor<T>, IIntegerRangeProperty> selector) =>
selector?.Invoke(new IntegerRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Ip(Func<IpPropertyDescriptor<T>, IIpProperty> selector) =>
selector?.Invoke(new IpPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty IpRange(Func<IpRangePropertyDescriptor<T>, IIpRangeProperty> selector) =>
selector?.Invoke(new IpRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Join(Func<JoinPropertyDescriptor<T>, IJoinProperty> selector) =>
selector?.Invoke(new JoinPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty FieldAlias(Func<FieldAliasPropertyDescriptor<T>, IFieldAliasProperty> selector) =>
selector?.Invoke(new FieldAliasPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty RankFeature(Func<RankFeaturePropertyDescriptor<T>, IRankFeatureProperty> selector) =>
selector?.Invoke(new RankFeaturePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty RankFeatures(Func<RankFeaturesPropertyDescriptor<T>, IRankFeaturesProperty> selector) =>
selector?.Invoke(new RankFeaturesPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Flattened(Func<FlattenedPropertyDescriptor<T>, IFlattenedProperty> selector) =>
selector?.Invoke(new FlattenedPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Keyword(Func<KeywordPropertyDescriptor<T>, IKeywordProperty> selector) =>
selector?.Invoke(new KeywordPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty LongRange(Func<LongRangePropertyDescriptor<T>, ILongRangeProperty> selector) =>
selector?.Invoke(new LongRangePropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Murmur3Hash(Func<Murmur3HashPropertyDescriptor<T>, IMurmur3HashProperty> selector) =>
selector?.Invoke(new Murmur3HashPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Nested<TChild>(Func<NestedPropertyDescriptor<T, TChild>, INestedProperty> selector)
where TChild : class => selector?.Invoke(new NestedPropertyDescriptor<T, TChild>());

Expand All @@ -70,21 +105,30 @@ public IProperty Nested<TChild>(Func<NestedPropertyDescriptor<T, TChild>, INeste
public IProperty Number(Func<NumberPropertyDescriptor<T>, INumberProperty> selector) =>
selector?.Invoke(new NumberPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Object<TChild>(Func<ObjectTypeDescriptor<T, TChild>, IObjectProperty> selector)
where TChild : class => selector?.Invoke(new ObjectTypeDescriptor<T, TChild>());

/// <inheritdoc />
public IProperty Percolator(Func<PercolatorPropertyDescriptor<T>, IPercolatorProperty> selector) =>
selector?.Invoke(new PercolatorPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Text(Func<TextPropertyDescriptor<T>, ITextProperty> selector) =>
selector?.Invoke(new TextPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty TokenCount(Func<TokenCountPropertyDescriptor<T>, ITokenCountProperty> selector) =>
selector?.Invoke(new TokenCountPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty Generic(Func<GenericPropertyDescriptor<T>, IGenericProperty> selector) =>
selector?.Invoke(new GenericPropertyDescriptor<T>());

/// <inheritdoc />
public IProperty SearchAsYouType(Func<SearchAsYouTypePropertyDescriptor<T>, ISearchAsYouTypeProperty> selector) =>
selector?.Invoke(new SearchAsYouTypePropertyDescriptor<T>());

#pragma warning disable CS3001 // Argument type is not CLS-compliant
public IProperty Scalar(Expression<Func<T, int>> field, Func<NumberPropertyDescriptor<T>, INumberProperty> selector = null) =>
selector.InvokeOrDefault(new NumberPropertyDescriptor<T>().Name(field).Type(NumberType.Integer));
Expand Down Expand Up @@ -319,9 +363,5 @@ public IProperty Scalar(Expression<Func<T, FloatRange>> field, Func<FloatRangePr
public IProperty Scalar(Expression<Func<T, IpAddressRange>> field, Func<IpRangePropertyDescriptor<T>, IIpRangeProperty> selector = null) =>
selector.InvokeOrDefault(new IpRangePropertyDescriptor<T>().Name(field));
#pragma warning restore CS3001 // Argument type is not CLS-compliant

/// <inheritdoc cref="ISearchAsYouTypeProperty"/>
public IProperty SearchAsYouType(Func<SearchAsYouTypePropertyDescriptor<T>, ISearchAsYouTypeProperty> selector) =>
selector?.Invoke(new SearchAsYouTypePropertyDescriptor<T>());
}
}
17 changes: 17 additions & 0 deletions src/Nest/Mapping/Types/Complex/Nested/NestedProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,40 @@

namespace Nest
{
/// <summary>
/// A specialised version of the <see cref="IObjectProperty"/> datatype that allows arrays of objects
/// to be indexed in a way that they can be queried independently of each other, using nested queries
/// and aggregations.
/// </summary>
[InterfaceDataContract]
public interface INestedProperty : IObjectProperty
{
/// <summary>
/// Whether to also index nested objects as flattened values on the parent document.
/// </summary>
[DataMember(Name = "include_in_parent")]
bool? IncludeInParent { get; set; }

/// <summary>
/// Whether to also index nested objects as flattened values on the root document.
/// </summary>
[DataMember(Name = "include_in_root")]
bool? IncludeInRoot { get; set; }
}

/// <inheritdoc cref="INestedProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class NestedProperty : ObjectProperty, INestedProperty
{
public NestedProperty() : base(FieldType.Nested) { }

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

/// <inheritdoc cref="INestedProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class NestedPropertyDescriptor<TParent, TChild>
: ObjectPropertyDescriptorBase<NestedPropertyDescriptor<TParent, TChild>, INestedProperty, TParent, TChild>
Expand All @@ -35,9 +50,11 @@ public NestedPropertyDescriptor() : base(FieldType.Nested) { }
bool? INestedProperty.IncludeInParent { get; set; }
bool? INestedProperty.IncludeInRoot { get; set; }

/// <inheritdoc cref="INestedProperty.IncludeInParent"/>
public NestedPropertyDescriptor<TParent, TChild> IncludeInParent(bool? includeInParent = true) =>
Assign(includeInParent, (a, v) => a.IncludeInParent = v);

/// <inheritdoc cref="INestedProperty.IncludeInRoot"/>
public NestedPropertyDescriptor<TParent, TChild> IncludeInRoot(bool? includeInRoot = true) =>
Assign(includeInRoot, (a, v) => a.IncludeInRoot = v);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Nest/Mapping/Types/Complex/Object/ObjectProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Nest
{
/// <summary>
/// A object datatype mapping for an inner object
/// A mapping for an inner object
/// </summary>
[InterfaceDataContract]
public interface IObjectProperty : ICoreProperty
Expand Down
4 changes: 4 additions & 0 deletions src/Nest/Mapping/Types/Core/Binary/BinaryProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

namespace Nest
{
/// <summary>
/// The binary type accepts a binary value as a Base64 encoded string.
/// The field is not stored by default and is not searchable
/// </summary>
[InterfaceDataContract]
public interface IBinaryProperty : IDocValuesProperty { }

Expand Down
3 changes: 3 additions & 0 deletions src/Nest/Mapping/Types/Core/Boolean/BooleanProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Nest
{
/// <summary>
/// The boolean fields accepts true and false values
/// </summary>
[InterfaceDataContract]
public interface IBooleanProperty : IDocValuesProperty
{
Expand Down
3 changes: 3 additions & 0 deletions src/Nest/Mapping/Types/Core/Date/DateProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Nest
{
/// <summary>
/// The date datatype maps a field as a date in Elasticsearch.
/// </summary>
[InterfaceDataContract]
public interface IDateProperty : IDocValuesProperty
{
Expand Down
5 changes: 5 additions & 0 deletions src/Nest/Mapping/Types/Core/DateNanos/DateNanosProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

namespace Nest
{
/// <summary>
/// The date nanos datatype is similar to <see cref="IDateProperty"/>, except that
/// internally, the date is stored with nanosecond resolution. This limits its range of
/// dates from roughly 1970 to 2262.
/// </summary>
[InterfaceDataContract]
public interface IDateNanosProperty : IDocValuesProperty
{
Expand Down
9 changes: 8 additions & 1 deletion src/Nest/Mapping/Types/Core/Join/JoinProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@

namespace Nest
{
/// <summary>
/// The join datatype is a special field that creates parent/child relation within documents of the same index.
/// </summary>
[InterfaceDataContract]
public interface IJoinProperty : IProperty
{
/// <summary>
/// Should the field be searchable? Accepts true (default) and false.
/// Defines a set of possible relations within the documents,
/// each relation being a parent name and a child name.
/// </summary>
[DataMember(Name = "relations")]
IRelations Relations { get; set; }
}

/// <inheritdoc cref="IJoinProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class JoinProperty : PropertyBase, IJoinProperty
{
Expand All @@ -23,6 +28,7 @@ public JoinProperty() : base(FieldType.Join) { }
public IRelations Relations { get; set; }
}

/// <inheritdoc cref="IJoinProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class JoinPropertyDescriptor<T> : PropertyDescriptorBase<JoinPropertyDescriptor<T>, IJoinProperty, T>, IJoinProperty
where T : class
Expand All @@ -31,6 +37,7 @@ public JoinPropertyDescriptor() : base(FieldType.Join) { }

IRelations IJoinProperty.Relations { get; set; }

/// <inheritdoc cref="IJoinProperty.Relations"/>
public JoinPropertyDescriptor<T> Relations(Func<RelationsDescriptor, IPromise<IRelations>> selector) =>
Assign(selector, (a, v) => a.Relations = v?.Invoke(new RelationsDescriptor())?.Value);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Nest/Mapping/Types/Core/Keyword/KeywordProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

namespace Nest
{
/// <summary>
/// A field to index structured content such as IDs, email addresses, hostnames, status codes, zip codes or tags.
/// Used for filtering, sorting, and for aggregations.
/// <para />
/// Keyword fields are only searchable by their exact value.
/// </summary>
[InterfaceDataContract]
public interface IKeywordProperty : IDocValuesProperty
{
Expand Down Expand Up @@ -36,6 +42,7 @@ public interface IKeywordProperty : IDocValuesProperty
bool? SplitQueriesOnWhitespace { get; set; }
}

/// <inheritdoc cref="IKeywordProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class KeywordProperty : DocValuesPropertyBase, IKeywordProperty
{
Expand All @@ -54,6 +61,7 @@ public KeywordProperty() : base(FieldType.Keyword) { }
public bool? SplitQueriesOnWhitespace { get; set; }
}

/// <inheritdoc cref="IKeywordProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class KeywordPropertyDescriptor<T>
: DocValuesPropertyDescriptorBase<KeywordPropertyDescriptor<T>, IKeywordProperty, T>, IKeywordProperty
Expand Down
3 changes: 3 additions & 0 deletions src/Nest/Mapping/Types/Core/Number/NumberProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Nest
{
/// <summary>
/// A numeric mapping that defaults to <c>float</c>.
/// </summary>
[InterfaceDataContract]
public interface INumberProperty : IDocValuesProperty
{
Expand Down
6 changes: 6 additions & 0 deletions src/Nest/Mapping/Types/Core/Percolator/PercolatorProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@

namespace Nest
{
/// <summary>
/// The percolator datatype is used to store a query, so that the
/// <see cref="IPercolateQuery"/> can use it to match provided documents.
/// </summary>
[InterfaceDataContract]
public interface IPercolatorProperty : IProperty { }

/// <inheritdoc cref="IPercolatorProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class PercolatorProperty : PropertyBase, IPercolatorProperty
{
public PercolatorProperty() : base(FieldType.Percolator) { }
}

/// <inheritdoc cref="IPercolatorProperty"/>
[DebuggerDisplay("{DebugDisplay}")]
public class PercolatorPropertyDescriptor<T>
: PropertyDescriptorBase<PercolatorPropertyDescriptor<T>, IPercolatorProperty, T>, IPercolatorProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IDateRangeProperty : IRangeProperty
string Format { get; set; }
}

/// <inheritdoc />
/// <inheritdoc cref="IDateRangeProperty" />
public class DateRangeProperty : RangePropertyBase, IDateRangeProperty
{
public DateRangeProperty() : base(RangeType.DateRange) { }
Expand All @@ -26,7 +26,7 @@ public DateRangeProperty() : base(RangeType.DateRange) { }
public string Format { get; set; }
}

/// <inheritdoc />
/// <inheritdoc cref="IDateRangeProperty" />
public class DateRangePropertyDescriptor<T>
: RangePropertyDescriptorBase<DateRangePropertyDescriptor<T>, IDateRangeProperty, T>, IDateRangeProperty
where T : class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Nest
[InterfaceDataContract]
public interface IDoubleRangeProperty : IRangeProperty { }

/// <inheritdoc />
/// <inheritdoc cref="IDoubleRangeProperty"/>
public class DoubleRangeProperty : RangePropertyBase, IDoubleRangeProperty
{
public DoubleRangeProperty() : base(RangeType.DoubleRange) { }
}

/// <inheritdoc />
/// <inheritdoc cref="IDoubleRangeProperty"/>
public class DoubleRangePropertyDescriptor<T>
: RangePropertyDescriptorBase<DoubleRangePropertyDescriptor<T>, IDoubleRangeProperty, T>, IDoubleRangeProperty
where T : class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Nest
[InterfaceDataContract]
public interface IFloatRangeProperty : IRangeProperty { }

/// <inheritdoc />
/// <inheritdoc cref="IFloatRangeProperty"/>
public class FloatRangeProperty : RangePropertyBase, IFloatRangeProperty
{
public FloatRangeProperty() : base(RangeType.FloatRange) { }
}

/// <inheritdoc />
/// <inheritdoc cref="IFloatRangeProperty"/>
public class FloatRangePropertyDescriptor<T>
: RangePropertyDescriptorBase<FloatRangePropertyDescriptor<T>, IFloatRangeProperty, T>, IFloatRangeProperty
where T : class
Expand Down
Loading