Skip to content

Commit be14c87

Browse files
committed
Removed string and added support for text and keyword properties
1 parent 201b7af commit be14c87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+700
-468
lines changed

Diff for: src/Nest/Mapping/DynamicTemplate/SingleMapping.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ public class SingleMappingDescriptor<T> :
66
DescriptorBase<SingleMappingDescriptor<T>, IPropertiesDescriptor<T, IProperty>>, IPropertiesDescriptor<T, IProperty>
77
where T : class
88
{
9-
public IProperty String(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
10-
selector?.Invoke(new StringPropertyDescriptor<T>());
9+
public IProperty Text(Func<TextPropertyDescriptor<T>, ITextProperty> selector) =>
10+
selector?.Invoke(new TextPropertyDescriptor<T>());
11+
12+
public IProperty Keyword(Func<KeywordPropertyDescriptor<T>, IKeywordProperty> selector) =>
13+
selector?.Invoke(new KeywordPropertyDescriptor<T>());
1114

1215
public IProperty Number(Func<NumberPropertyDescriptor<T>, INumberProperty> selector) =>
1316
selector?.Invoke(new NumberPropertyDescriptor<T>());
@@ -48,4 +51,4 @@ public IProperty Murmur3Hash(Func<Murmur3HashPropertyDescriptor<T>, IMurmur3Hash
4851
public IProperty TokenCount(Func<TokenCountPropertyDescriptor<T>, ITokenCountProperty> selector) =>
4952
selector?.Invoke(new TokenCountPropertyDescriptor<T>());
5053
}
51-
}
54+
}

Diff for: src/Nest/Mapping/SimilarityOption.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Nest
77
[JsonConverter(typeof(StringEnumConverter))]
88
public enum SimilarityOption
99
{
10-
[EnumMember(Value = "default")]
11-
Default,
10+
[EnumMember(Value = "classic")]
11+
Classic,
1212
[EnumMember(Value = "BM25")]
1313
BM25
1414
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Nest
8+
{
9+
public class KeywordAttribute : ElasticsearchPropertyAttributeBase, IKeywordProperty
10+
{
11+
IKeywordProperty Self => this;
12+
13+
double? IKeywordProperty.Boost { get; set; }
14+
bool? IKeywordProperty.EagerGlobalOrdinals { get; set; }
15+
int? IKeywordProperty.IgnoreAbove { get; set; }
16+
bool? IKeywordProperty.IncludeInAll { get; set; }
17+
bool? IKeywordProperty.Index { get; set; }
18+
IndexOptions? IKeywordProperty.IndexOptions { get; set; }
19+
INorms IKeywordProperty.Norms { get; set; }
20+
string IKeywordProperty.NullValue { get; set; }
21+
string IKeywordProperty.SearchAnalyzer { get; set; }
22+
23+
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
24+
public bool EagerGlobalOrdinals { get { return Self.EagerGlobalOrdinals.GetValueOrDefault(); } set { Self.EagerGlobalOrdinals = value; } }
25+
public int IgnoreAbove { get { return Self.IgnoreAbove.GetValueOrDefault(); } set { Self.IgnoreAbove = value; } }
26+
public bool IncludeInAll { get { return Self.IncludeInAll.GetValueOrDefault(); } set { Self.IncludeInAll = value; } }
27+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
28+
public IndexOptions IndexOptions { get { return Self.IndexOptions.GetValueOrDefault(); } set { Self.IndexOptions = value; } }
29+
public string NullValue { get { return Self.NullValue; } set { Self.NullValue = value; } }
30+
public string SearchAnalyzer { get { return Self.SearchAnalyzer; } set { Self.SearchAnalyzer = value; } }
31+
32+
public KeywordAttribute() : base("keyword") { }
33+
}
34+
}
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Nest
9+
{
10+
[JsonObject(MemberSerialization.OptIn)]
11+
public interface IKeywordProperty : IProperty
12+
{
13+
[JsonProperty("boost")]
14+
double? Boost { get; set; }
15+
16+
[JsonProperty("eager_global_ordinals")]
17+
bool? EagerGlobalOrdinals { get; set; }
18+
19+
[JsonProperty("ignore_above")]
20+
int? IgnoreAbove { get; set; }
21+
22+
[JsonProperty("include_in_all")]
23+
bool? IncludeInAll { get; set; }
24+
25+
[JsonProperty("index")]
26+
bool? Index { get; set; }
27+
28+
[JsonProperty("index_options")]
29+
IndexOptions? IndexOptions { get; set; }
30+
31+
// TODO should this be bool?
32+
[JsonProperty("norms")]
33+
INorms Norms { get; set; }
34+
35+
[JsonProperty("null_value")]
36+
string NullValue { get; set; }
37+
38+
[JsonProperty("search_analyzer")]
39+
string SearchAnalyzer { get; set; }
40+
}
41+
42+
public class KeywordProperty : PropertyBase, IKeywordProperty
43+
{
44+
public KeywordProperty() : base("keyword") { }
45+
46+
public double? Boost { get; set; }
47+
public bool? EagerGlobalOrdinals { get; set; }
48+
public int? IgnoreAbove { get; set; }
49+
public bool? IncludeInAll { get; set; }
50+
public bool? Index { get; set; }
51+
public IndexOptions? IndexOptions { get; set; }
52+
public INorms Norms { get; set; }
53+
public string NullValue { get; set; }
54+
public string SearchAnalyzer { get; set; }
55+
}
56+
57+
public class KeywordPropertyDescriptor<T>
58+
: PropertyDescriptorBase<KeywordPropertyDescriptor<T>, IKeywordProperty, T>, IKeywordProperty
59+
where T : class
60+
{
61+
double? IKeywordProperty.Boost { get; set; }
62+
bool? IKeywordProperty.EagerGlobalOrdinals{ get; set; }
63+
int? IKeywordProperty.IgnoreAbove{ get; set; }
64+
bool? IKeywordProperty.IncludeInAll{ get; set; }
65+
bool? IKeywordProperty.Index{ get; set; }
66+
IndexOptions? IKeywordProperty.IndexOptions{ get; set; }
67+
INorms IKeywordProperty.Norms{ get; set; }
68+
string IKeywordProperty.NullValue{ get; set; }
69+
string IKeywordProperty.SearchAnalyzer{ get; set; }
70+
71+
public KeywordPropertyDescriptor() : base("keyword") { }
72+
73+
public KeywordPropertyDescriptor<T> Boost(double boost) => Assign(a => a.Boost = boost);
74+
public KeywordPropertyDescriptor<T> EagerGlobalOrdinals(bool eagerGlobalOrdinals = true) => Assign(a => a.EagerGlobalOrdinals = eagerGlobalOrdinals);
75+
public KeywordPropertyDescriptor<T> IgnoreAbove(int ignoreAbove) => Assign(a => a.IgnoreAbove = ignoreAbove);
76+
public KeywordPropertyDescriptor<T> IncludeInAll(bool includeInAll = true) => Assign(a => a.IncludeInAll = includeInAll);
77+
public KeywordPropertyDescriptor<T> Index(bool index = true) => Assign(a => a.Index = index);
78+
public KeywordPropertyDescriptor<T> IndexOptions(IndexOptions indexOptions) => Assign(a => a.IndexOptions = indexOptions);
79+
public KeywordPropertyDescriptor<T> Norms(Func<NormsDescriptor, INorms> selector) => Assign(a => a.Norms = selector?.Invoke(new NormsDescriptor()));
80+
public KeywordPropertyDescriptor<T> NullValue(string nullValue) => Assign(a => a.NullValue = nullValue);
81+
public KeywordPropertyDescriptor<T> SearchAnalyzer(string searchAnalyzer) => Assign(a => a.SearchAnalyzer = searchAnalyzer);
82+
}
83+
}

Diff for: src/Nest/Mapping/Types/Core/String/StringAttribute.cs

-33
This file was deleted.

Diff for: src/Nest/Mapping/Types/Core/String/StringProperty.cs

-113
This file was deleted.

Diff for: src/Nest/Mapping/Types/Core/Text/TextAttribute.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Nest
8+
{
9+
public class TextAttribute : ElasticsearchPropertyAttributeBase, ITextProperty
10+
{
11+
ITextProperty Self => this;
12+
13+
string ITextProperty.Analyzer { get; set; }
14+
double? ITextProperty.Boost { get; set; }
15+
bool? ITextProperty.EagerGlobalOrdinals { get; set; }
16+
bool? ITextProperty.Fielddata { get; set; }
17+
IFielddataFrequencyFilter ITextProperty.FielddataFrequencyFilter { get; set; }
18+
bool? ITextProperty.IncludeInAll { get; set; }
19+
bool? ITextProperty.Index { get; set; }
20+
IndexOptions? ITextProperty.IndexOptions { get; set; }
21+
INorms ITextProperty.Norms { get; set; }
22+
int? ITextProperty.PositionIncrementGap { get; set; }
23+
string ITextProperty.SearchAnalyzer { get; set; }
24+
string ITextProperty.SearchQuoteAnalyzer { get; set; }
25+
TermVectorOption? ITextProperty.TermVector { get; set; }
26+
27+
public string Analyzer { get { return Self.Analyzer; } set { Self.Analyzer = value; } }
28+
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
29+
public bool EagerGlobalOrdinals { get { return Self.EagerGlobalOrdinals.GetValueOrDefault(); } set { Self.EagerGlobalOrdinals = value; } }
30+
public bool Fielddata { get { return Self.Fielddata.GetValueOrDefault(); } set { Self.Fielddata = value; } }
31+
public bool IncludeInAll { get { return Self.IncludeInAll.GetValueOrDefault(); } set { Self.IncludeInAll = value; } }
32+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
33+
public IndexOptions IndexOptions { get { return Self.IndexOptions.GetValueOrDefault(); } set { Self.IndexOptions = value; } }
34+
public int PositionIncrementGap { get { return Self.PositionIncrementGap.GetValueOrDefault(); } set { Self.PositionIncrementGap = value; } }
35+
public string SearchAnalyzer { get { return Self.SearchAnalyzer; } set { Self.SearchAnalyzer = value; } }
36+
public string SearchQuoteAnalyzer { get { return Self.SearchQuoteAnalyzer; } set { Self.SearchQuoteAnalyzer = value; } }
37+
38+
public TextAttribute() : base("text") { }
39+
}
40+
}

0 commit comments

Comments
 (0)