Skip to content

Commit cc0ff50

Browse files
gmarzMpdreamz
authored andcommitted
Mark type level analyzers as obsolete and add a convenience method fo… (#2506)
* Mark type level analyzers as obsolete and add a convenience method for setting an index-level default * remove Default() Conflicts: src/Tests/Analysis/Analyzers/AnalyzerUsageTests.cs
1 parent 6cde14f commit cc0ff50

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Nest/Mapping/TypeMapping.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ public interface ITypeMapping
2525
[JsonProperty("include_in_all")]
2626
bool? IncludeInAll { get; set; }
2727

28+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
2829
[JsonProperty("analyzer")]
2930
string Analyzer { get; set; }
3031

32+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
3133
[JsonProperty("search_analyzer")]
3234
string SearchAnalyzer { get; set; }
3335

@@ -79,8 +81,6 @@ public class TypeMapping : ITypeMapping
7981
/// <inheritdoc/>
8082
public IAllField AllField { get; set; }
8183
/// <inheritdoc/>
82-
public string Analyzer { get; set; }
83-
/// <inheritdoc/>
8484
public bool? DateDetection { get; set; }
8585
/// <inheritdoc/>
8686
public DynamicMapping? Dynamic { get; set; }
@@ -105,6 +105,10 @@ public class TypeMapping : ITypeMapping
105105
/// <inheritdoc/>
106106
public IRoutingField RoutingField { get; set; }
107107
/// <inheritdoc/>
108+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
109+
public string Analyzer { get; set; }
110+
/// <inheritdoc/>
111+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
108112
public string SearchAnalyzer { get; set; }
109113
/// <inheritdoc/>
110114
public ISizeField SizeField { get; set; }
@@ -126,7 +130,6 @@ public class TypeMappingDescriptor<T> : DescriptorBase<TypeMappingDescriptor<T>,
126130
where T : class
127131
{
128132
IAllField ITypeMapping.AllField { get; set; }
129-
string ITypeMapping.Analyzer { get; set; }
130133
bool? ITypeMapping.DateDetection { get; set; }
131134
bool? ITypeMapping.IncludeInAll { get; set; }
132135
DynamicMapping? ITypeMapping.Dynamic { get; set; }
@@ -139,6 +142,9 @@ public class TypeMappingDescriptor<T> : DescriptorBase<TypeMappingDescriptor<T>,
139142
IParentField ITypeMapping.ParentField { get; set; }
140143
IProperties ITypeMapping.Properties { get; set; }
141144
IRoutingField ITypeMapping.RoutingField { get; set; }
145+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
146+
string ITypeMapping.Analyzer { get; set; }
147+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
142148
string ITypeMapping.SearchAnalyzer { get; set; }
143149
ISizeField ITypeMapping.SizeField { get; set; }
144150
ISourceField ITypeMapping.SourceField { get; set; }
@@ -177,9 +183,11 @@ public TypeMappingDescriptor<T> AutoMap(IPropertyVisitor visitor = null, int max
177183
public TypeMappingDescriptor<T> Parent<TOther>() where TOther : class => Assign(a => a.ParentField = new ParentField { Type = typeof(TOther) });
178184

179185
/// <inheritdoc/>
186+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
180187
public TypeMappingDescriptor<T> Analyzer(string analyzer) => Assign(a => a.Analyzer = analyzer);
181188

182189
/// <inheritdoc/>
190+
[Obsolete("Scheduled to be removed in 6.0. Default analyzers can no longer be specified at the type level. Use an index or field level analyzer instead.")]
183191
public TypeMappingDescriptor<T> SearchAnalyzer(string searchAnalyzer)=> Assign(a => a.SearchAnalyzer = searchAnalyzer);
184192

185193
/// <inheritdoc/>

src/Tests/Analysis/Analyzers/AnalyzerUsageTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public class AnalyzerUsageTests : PromiseUsageTestBase<IIndexSettings, IndexSett
1515
{
1616
analyzer = new
1717
{
18+
@default = new
19+
{
20+
type = "keyword"
21+
},
1822
myCustom = new
1923
{
2024
type = "custom",
@@ -72,6 +76,7 @@ public class AnalyzerUsageTests : PromiseUsageTestBase<IIndexSettings, IndexSett
7276
public static Func<IndexSettingsDescriptor, IPromise<IndexSettings>> FluentExample => s => s
7377
.Analysis(analysis => analysis
7478
.Analyzers(analyzers => analyzers
79+
.Keyword("default")
7580
.Custom("myCustom", a => a
7681
.Filters("myAscii", "kstem")
7782
.CharFilters("stripMe", "patterned")
@@ -99,6 +104,7 @@ public class AnalyzerUsageTests : PromiseUsageTestBase<IIndexSettings, IndexSett
99104
{
100105
Analyzers = new Nest.Analyzers
101106
{
107+
{ "default", new KeywordAnalyzer() },
102108
{ "myCustom", new CustomAnalyzer
103109
{
104110
CharFilter = new [] { "stripMe", "patterned"},

0 commit comments

Comments
 (0)