Skip to content

Commit 694b366

Browse files
committed
Merge pull request #2026 from elastic/fix/1979
Add not_analyzed to NonStringIndexOption and make it the default option
2 parents 193355f + 5c21120 commit 694b366

File tree

7 files changed

+32
-19
lines changed

7 files changed

+32
-19
lines changed

src/Nest/Mapping/NonStringIndexOption.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace Nest
77
[JsonConverter(typeof(StringEnumConverter))]
88
public enum NonStringIndexOption
99
{
10+
[EnumMember(Value = "not_analyzed")]
11+
NotAnalyzed,
1012
[EnumMember(Value = "no")]
1113
No
1214
}

src/Nest/Mapping/Types/Core/Boolean/BooleanProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface IBooleanProperty : IProperty
1919
[JsonProperty("fielddata")]
2020
INumericFielddata Fielddata { get; set; }
2121
}
22-
22+
2323
public class BooleanProperty : PropertyBase, IBooleanProperty
2424
{
2525
public BooleanProperty() : base("boolean") { }
@@ -42,9 +42,9 @@ public class BooleanPropertyDescriptor<T>
4242
public BooleanPropertyDescriptor() : base("boolean") { }
4343

4444
public BooleanPropertyDescriptor<T> Boost(double boost) => Assign(a => a.Boost = boost);
45-
public BooleanPropertyDescriptor<T> Index(NonStringIndexOption index) => Assign(a => a.Index = index);
45+
public BooleanPropertyDescriptor<T> Index(NonStringIndexOption index = NonStringIndexOption.NotAnalyzed) => Assign(a => a.Index = index);
4646
public BooleanPropertyDescriptor<T> NullValue(bool nullValue) => Assign(a => a.NullValue = nullValue);
4747
public BooleanPropertyDescriptor<T> Fielddata(Func<NumericFielddataDescriptor, INumericFielddata> selector) =>
4848
Assign(a => a.Fielddata = selector(new NumericFielddataDescriptor()));
4949
}
50-
}
50+
}

src/Nest/Mapping/Types/Core/Date/DateProperty.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public interface IDateProperty : IProperty
2020

2121
[JsonProperty("precision_step")]
2222
int? PrecisionStep { get; set; }
23-
23+
2424
[JsonProperty("ignore_malformed")]
2525
bool? IgnoreMalformed { get; set; }
26-
26+
2727
[JsonProperty("format")]
2828
string Format { get; set; }
29-
29+
3030
[JsonProperty("numeric_resolution")]
3131
NumericResolutionUnit? NumericResolution { get; set; }
3232

@@ -49,7 +49,7 @@ public DateProperty() : base("date") { }
4949
public INumericFielddata Fielddata { get; set; }
5050
}
5151

52-
public class DatePropertyDescriptor<T>
52+
public class DatePropertyDescriptor<T>
5353
: PropertyDescriptorBase<DatePropertyDescriptor<T>, IDateProperty, T>, IDateProperty
5454
where T : class
5555
{
@@ -65,7 +65,7 @@ public class DatePropertyDescriptor<T>
6565

6666
public DatePropertyDescriptor() : base("date") { }
6767

68-
public DatePropertyDescriptor<T> Index(NonStringIndexOption index = NonStringIndexOption.No) => Assign(a => a.Index = index);
68+
public DatePropertyDescriptor<T> Index(NonStringIndexOption index = NonStringIndexOption.NotAnalyzed) => Assign(a => a.Index = index);
6969
public DatePropertyDescriptor<T> Boost(double boost) => Assign(a => a.Boost = boost);
7070
public DatePropertyDescriptor<T> NullValue(DateTime nullValue) => Assign(a => a.NullValue = nullValue);
7171
public DatePropertyDescriptor<T> IncludeInAll(bool includeInAll = true) => Assign(a => a.IncludeInAll = includeInAll);
@@ -76,4 +76,4 @@ public DatePropertyDescriptor() : base("date") { }
7676
public DatePropertyDescriptor<T> Fielddata(Func<NumericFielddataDescriptor, INumericFielddata> selector) =>
7777
Assign(a => a.Fielddata = selector(new NumericFielddataDescriptor()));
7878
}
79-
}
79+
}

src/Nest/Mapping/Types/Core/Number/NumberProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected NumberPropertyDescriptorBase(string type) : base(type) { }
6868

6969
public TDescriptor Type(NumberType type) => Assign(a => a.Type = type.GetStringValue());
7070

71-
public TDescriptor Index(NonStringIndexOption index = NonStringIndexOption.No) => Assign(a => a.Index = index);
71+
public TDescriptor Index(NonStringIndexOption index = NonStringIndexOption.NotAnalyzed) => Assign(a => a.Index = index);
7272

7373
public TDescriptor Boost(double boost) => Assign(a => a.Boost = boost);
7474

@@ -86,9 +86,9 @@ public TDescriptor Fielddata(Func<NumericFielddataDescriptor, INumericFielddata>
8686
Assign(a => a.Fielddata = selector(new NumericFielddataDescriptor()));
8787
}
8888

89-
public class NumberPropertyDescriptor<T>
89+
public class NumberPropertyDescriptor<T>
9090
: NumberPropertyDescriptorBase<NumberPropertyDescriptor<T>, INumberProperty, T>, INumberProperty
9191
where T : class
9292
{
9393
}
94-
}
94+
}

src/Nest/Mapping/Types/Specialized/Ip/IpProperty.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class IpPropertyDescriptor<T>
4444

4545
public IpPropertyDescriptor() : base("ip") { }
4646

47-
public IpPropertyDescriptor<T> Index(NonStringIndexOption? index) => Assign(a => a.Index = index);
47+
public IpPropertyDescriptor<T> Index(NonStringIndexOption? index = NonStringIndexOption.NotAnalyzed) => Assign(a => a.Index = index);
4848

4949
public IpPropertyDescriptor<T> Boost(double boost) => Assign(a => a.Boost = boost);
5050

@@ -54,4 +54,4 @@ public IpPropertyDescriptor() : base("ip") { }
5454

5555
public IpPropertyDescriptor<T> IncludeInAll(bool includeInAll = true) => Assign(a => a.IncludeInAll = includeInAll);
5656
}
57-
}
57+
}

src/Nest/Mapping/Types/Specialized/TokenCount/TokenCountProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public TokenCountProperty() : base("token_count") { }
1616
public string Analyzer { get; set; }
1717
}
1818

19-
public class TokenCountPropertyDescriptor<T>
19+
public class TokenCountPropertyDescriptor<T>
2020
: NumberPropertyDescriptorBase<TokenCountPropertyDescriptor<T>, ITokenCountProperty, T>, ITokenCountProperty
2121
where T : class
2222
{

src/Tests/Indices/MappingManagement/PutMapping/PutMappingApiTest.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ protected override LazyResponses ClientUsage() => Calls(
123123
},
124124
numberOfCommits = new
125125
{
126-
type = "integer"
126+
type = "integer",
127+
index = "not_analyzed"
127128
},
128129
startedOn = new
129130
{
130-
type = "date"
131+
type = "date",
132+
index = "no"
131133
},
132134
state = new
133135
{
@@ -160,6 +162,15 @@ protected override LazyResponses ClientUsage() => Calls(
160162
.Index(CallIsolatedValue)
161163
.AutoMap()
162164
.Properties(prop => prop
165+
.Number(n => n
166+
.Name(p => p.NumberOfCommits)
167+
.Type(NumberType.Integer)
168+
.Index()
169+
)
170+
.Date(dt => dt
171+
.Name(p => p.StartedOn)
172+
.Index(NonStringIndexOption.No)
173+
)
163174
.String(s => s
164175
.Name(p => p.Name)
165176
.NotAnalyzed()
@@ -211,8 +222,8 @@ protected override LazyResponses ClientUsage() => Calls(
211222
},
212223
{ p => p.Metadata, new ObjectProperty() },
213224
{ p => p.Name, new StringProperty { Index = FieldIndexOption.NotAnalyzed } },
214-
{ p => p.NumberOfCommits, new NumberProperty(NumberType.Integer) },
215-
{ p => p.StartedOn, new DateProperty() },
225+
{ p => p.NumberOfCommits, new NumberProperty(NumberType.Integer) { Index = NonStringIndexOption.NotAnalyzed } },
226+
{ p => p.StartedOn, new DateProperty { Index = NonStringIndexOption.No } },
216227
{ p => p.State, new NumberProperty(NumberType.Integer) },
217228
{ p => p.Suggest, new CompletionProperty() },
218229
{ p => p.Tags, new ObjectProperty

0 commit comments

Comments
 (0)