Skip to content

Commit 3b4466e

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()
1 parent d4fcc92 commit 3b4466e

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
@@ -20,9 +20,11 @@ public interface ITypeMapping
2020
[JsonProperty("include_in_all")]
2121
bool? IncludeInAll { get; set; }
2222

23+
[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.")]
2324
[JsonProperty("analyzer")]
2425
string Analyzer { get; set; }
2526

27+
[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.")]
2628
[JsonProperty("search_analyzer")]
2729
string SearchAnalyzer { get; set; }
2830

@@ -66,8 +68,6 @@ public class TypeMapping : ITypeMapping
6668
/// <inheritdoc/>
6769
public IAllField AllField { get; set; }
6870
/// <inheritdoc/>
69-
public string Analyzer { get; set; }
70-
/// <inheritdoc/>
7171
public bool? DateDetection { get; set; }
7272
/// <inheritdoc/>
7373
public bool? IncludeInAll { get; set; }
@@ -92,6 +92,10 @@ public class TypeMapping : ITypeMapping
9292
/// <inheritdoc/>
9393
public IRoutingField RoutingField { get; set; }
9494
/// <inheritdoc/>
95+
[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.")]
96+
public string Analyzer { get; set; }
97+
/// <inheritdoc/>
98+
[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.")]
9599
public string SearchAnalyzer { get; set; }
96100
/// <inheritdoc/>
97101
public ISizeField SizeField { get; set; }
@@ -105,7 +109,6 @@ public class TypeMappingDescriptor<T> : DescriptorBase<TypeMappingDescriptor<T>,
105109
where T : class
106110
{
107111
IAllField ITypeMapping.AllField { get; set; }
108-
string ITypeMapping.Analyzer { get; set; }
109112
bool? ITypeMapping.DateDetection { get; set; }
110113
bool? ITypeMapping.IncludeInAll { get; set; }
111114
Union<bool, DynamicMapping> ITypeMapping.Dynamic { get; set; }
@@ -118,6 +121,9 @@ public class TypeMappingDescriptor<T> : DescriptorBase<TypeMappingDescriptor<T>,
118121
IParentField ITypeMapping.ParentField { get; set; }
119122
IProperties ITypeMapping.Properties { get; set; }
120123
IRoutingField ITypeMapping.RoutingField { get; set; }
124+
[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.")]
125+
string ITypeMapping.Analyzer { get; set; }
126+
[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.")]
121127
string ITypeMapping.SearchAnalyzer { get; set; }
122128
ISizeField ITypeMapping.SizeField { get; set; }
123129
ISourceField ITypeMapping.SourceField { get; set; }
@@ -150,9 +156,11 @@ public TypeMappingDescriptor<T> AutoMap(IPropertyVisitor visitor = null, int max
150156
public TypeMappingDescriptor<T> Parent<TOther>() where TOther : class => Assign(a => a.ParentField = new ParentField { Type = typeof(TOther) });
151157

152158
/// <inheritdoc/>
159+
[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.")]
153160
public TypeMappingDescriptor<T> Analyzer(string analyzer) => Assign(a => a.Analyzer = analyzer);
154161

155162
/// <inheritdoc/>
163+
[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.")]
156164
public TypeMappingDescriptor<T> SearchAnalyzer(string searchAnalyzer)=> Assign(a => a.SearchAnalyzer = searchAnalyzer);
157165

158166
/// <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",
@@ -78,6 +82,7 @@ public class AnalyzerUsageTests : PromiseUsageTestBase<IIndexSettings, IndexSett
7882
public static Func<IndexSettingsDescriptor, IPromise<IndexSettings>> FluentExample => s => s
7983
.Analysis(analysis => analysis
8084
.Analyzers(analyzers => analyzers
85+
.Keyword("default")
8186
.Custom("myCustom", a => a
8287
.Filters("myAscii", "kstem")
8388
.CharFilters("stripMe", "patterned")
@@ -111,6 +116,7 @@ public class AnalyzerUsageTests : PromiseUsageTestBase<IIndexSettings, IndexSett
111116
{
112117
Analyzers = new Nest.Analyzers
113118
{
119+
{ "default", new KeywordAnalyzer() },
114120
{ "myCustom", new CustomAnalyzer
115121
{
116122
CharFilter = new [] { "stripMe", "patterned"},

0 commit comments

Comments
 (0)