|
| 1 | +using System.Diagnostics; |
| 2 | +using System.Runtime.Serialization; |
| 3 | +using Elasticsearch.Net.Utf8Json; |
| 4 | + |
| 5 | +namespace Nest |
| 6 | +{ |
| 7 | + /// <summary> |
| 8 | + /// Constant keyword is a specialization of the keyword field for the case that all documents in the index have the same value. |
| 9 | + /// <para /> |
| 10 | + /// Available in Elasticsearch 7.7.0+ with at least a basic license level |
| 11 | + /// </summary> |
| 12 | + [InterfaceDataContract] |
| 13 | + public interface IConstantKeywordProperty : IProperty |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// The value to associate with all documents in the index. |
| 17 | + /// If this parameter is not provided, it is set based on the first document that gets indexed. |
| 18 | + /// <para /> |
| 19 | + /// Value must be a string or a numeric value |
| 20 | + /// </summary> |
| 21 | + [DataMember(Name ="value")] |
| 22 | + object Value { get; set; } |
| 23 | + } |
| 24 | + |
| 25 | + /// <inheritdoc cref="IConstantKeywordProperty" /> |
| 26 | + [DebuggerDisplay("{DebugDisplay}")] |
| 27 | + public class ConstantKeywordProperty : PropertyBase, IConstantKeywordProperty |
| 28 | + { |
| 29 | + public ConstantKeywordProperty() : base(FieldType.ConstantKeyword) { } |
| 30 | + |
| 31 | + /// <inheritdoc cref="IConstantKeywordProperty.Value" /> |
| 32 | + public object Value { get; set; } |
| 33 | + } |
| 34 | + |
| 35 | + /// <inheritdoc cref="IConstantKeywordProperty" /> |
| 36 | + [DebuggerDisplay("{DebugDisplay}")] |
| 37 | + public class ConstantKeywordPropertyDescriptor<T> |
| 38 | + : PropertyDescriptorBase<ConstantKeywordPropertyDescriptor<T>, IConstantKeywordProperty, T>, IConstantKeywordProperty |
| 39 | + where T : class |
| 40 | + { |
| 41 | + public ConstantKeywordPropertyDescriptor() : base(FieldType.ConstantKeyword) { } |
| 42 | + |
| 43 | + object IConstantKeywordProperty.Value { get; set; } |
| 44 | + |
| 45 | + /// <inheritdoc cref="IConstantKeywordProperty.Value" /> |
| 46 | + public ConstantKeywordPropertyDescriptor<T> Value(object value) => Assign(value, (a, v) => a.Value = v); |
| 47 | + } |
| 48 | +} |
0 commit comments