Skip to content

Commit e04f6e5

Browse files
committed
Index property on property mappings now only accepts true/false
Fixes #1998
1 parent a84e56f commit e04f6e5

16 files changed

+57
-66
lines changed

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

-13
This file was deleted.

Diff for: src/Nest/Mapping/Types/Core/Boolean/BooleanAttribute.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ public class BooleanAttribute : ElasticsearchPropertyAttributeBase, IBooleanProp
44
{
55
IBooleanProperty Self => this;
66

7-
NonStringIndexOption? IBooleanProperty.Index { get; set; }
7+
bool? IBooleanProperty.Index { get; set; }
88
double? IBooleanProperty.Boost { get; set; }
99
bool? IBooleanProperty.NullValue { get; set; }
1010
INumericFielddata IBooleanProperty.Fielddata { get; set; }
1111

12-
public NonStringIndexOption Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
12+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
1313
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
1414
public bool NullValue { get { return Self.NullValue.GetValueOrDefault(); } set { Self.NullValue = value; } }
1515

1616
public BooleanAttribute() : base("boolean") { }
17-
}
17+
}
1818
}

Diff for: src/Nest/Mapping/Types/Core/Boolean/BooleanProperty.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Nest
88
public interface IBooleanProperty : IProperty
99
{
1010
[JsonProperty("index")]
11-
NonStringIndexOption? Index { get; set; }
11+
bool? Index { get; set; }
1212

1313
[JsonProperty("boost")]
1414
double? Boost { get; set; }
@@ -19,12 +19,12 @@ 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") { }
2626

27-
public NonStringIndexOption? Index { get; set; }
27+
public bool? Index { get; set; }
2828
public double? Boost { get; set; }
2929
public bool? NullValue { get; set; }
3030
public INumericFielddata Fielddata { get; set; }
@@ -35,16 +35,16 @@ public class BooleanPropertyDescriptor<T>
3535
where T : class
3636
{
3737
double? IBooleanProperty.Boost { get; set; }
38-
NonStringIndexOption? IBooleanProperty.Index { get; set; }
38+
bool? IBooleanProperty.Index { get; set; }
3939
bool? IBooleanProperty.NullValue { get; set; }
4040
INumericFielddata IBooleanProperty.Fielddata { get; set; }
4141

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(bool index) => 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+
}

Diff for: src/Nest/Mapping/Types/Core/Date/DateAttribute.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class DateAttribute : ElasticsearchPropertyAttributeBase, IDateProperty
66
{
77
IDateProperty Self => this;
88

9-
NonStringIndexOption? IDateProperty.Index { get; set; }
9+
bool? IDateProperty.Index { get; set; }
1010
double? IDateProperty.Boost { get; set; }
1111
DateTime? IDateProperty.NullValue { get; set; }
1212
bool? IDateProperty.IncludeInAll { get; set; }
@@ -16,7 +16,7 @@ public class DateAttribute : ElasticsearchPropertyAttributeBase, IDateProperty
1616
NumericResolutionUnit? IDateProperty.NumericResolution { get; set; }
1717
INumericFielddata IDateProperty.Fielddata { get; set; }
1818

19-
public NonStringIndexOption Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
19+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
2020
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
2121
public DateTime NullValue { get { return Self.NullValue.GetValueOrDefault(); } set { Self.NullValue = value; } }
2222
public bool IncludeInAll { get { return Self.IncludeInAll.GetValueOrDefault(); } set { Self.IncludeInAll = value; } }
@@ -26,5 +26,5 @@ public class DateAttribute : ElasticsearchPropertyAttributeBase, IDateProperty
2626
public NumericResolutionUnit NumericResolution { get { return Self.NumericResolution.GetValueOrDefault(); } set { Self.NumericResolution = value; } }
2727

2828
public DateAttribute() : base("date") { }
29-
}
29+
}
3030
}

Diff for: src/Nest/Mapping/Types/Core/Date/DateProperty.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Nest
77
public interface IDateProperty : IProperty
88
{
99
[JsonProperty("index")]
10-
NonStringIndexOption? Index { get; set; }
10+
bool? Index { get; set; }
1111

1212
[JsonProperty("boost")]
1313
double? Boost { get; set; }
@@ -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

@@ -38,7 +38,7 @@ public class DateProperty : PropertyBase, IDateProperty
3838
{
3939
public DateProperty() : base("date") { }
4040

41-
public NonStringIndexOption? Index { get; set; }
41+
public bool? Index { get; set; }
4242
public double? Boost { get; set; }
4343
public DateTime? NullValue { get; set; }
4444
public bool? IncludeInAll { get; set; }
@@ -49,11 +49,11 @@ 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
{
56-
NonStringIndexOption? IDateProperty.Index { get; set; }
56+
bool? IDateProperty.Index { get; set; }
5757
double? IDateProperty.Boost { get; set; }
5858
DateTime? IDateProperty.NullValue { get; set; }
5959
bool? IDateProperty.IncludeInAll { get; set; }
@@ -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(bool index) => 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+
}

Diff for: src/Nest/Mapping/Types/Core/Number/NumberAttribute.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class NumberAttribute : ElasticsearchPropertyAttributeBase, INumberProper
44
{
55
INumberProperty Self => this;
66

7-
NonStringIndexOption? INumberProperty.Index { get; set; }
7+
bool? INumberProperty.Index { get; set; }
88
double? INumberProperty.Boost { get; set; }
99
double? INumberProperty.NullValue { get; set; }
1010
bool? INumberProperty.IncludeInAll { get; set; }
@@ -13,7 +13,7 @@ public class NumberAttribute : ElasticsearchPropertyAttributeBase, INumberProper
1313
bool? INumberProperty.Coerce { get; set; }
1414
INumericFielddata INumberProperty.Fielddata { get; set; }
1515

16-
public NonStringIndexOption Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
16+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
1717
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
1818
public double NullValue { get { return Self.NullValue.GetValueOrDefault(); } set { Self.NullValue = value; } }
1919
public bool IncludeInAll { get { return Self.IncludeInAll.GetValueOrDefault(); } set { Self.IncludeInAll = value; } }

Diff for: src/Nest/Mapping/Types/Core/Number/NumberProperty.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Nest
77
public interface INumberProperty : IProperty
88
{
99
[JsonProperty("index")]
10-
NonStringIndexOption? Index { get; set; }
10+
bool? Index { get; set; }
1111

1212
[JsonProperty("boost")]
1313
double? Boost { get; set; }
@@ -37,7 +37,7 @@ public NumberProperty() : base(NumberType.Double.GetStringValue()) { }
3737
public NumberProperty(NumberType type) : base(type.GetStringValue()) { }
3838
protected NumberProperty(string type) : base(type) { }
3939

40-
public NonStringIndexOption? Index { get; set; }
40+
public bool? Index { get; set; }
4141
public double? Boost { get; set; }
4242
public double? NullValue { get; set; }
4343
public bool? IncludeInAll { get; set; }
@@ -53,11 +53,11 @@ public abstract class NumberPropertyDescriptorBase<TDescriptor, TInterface, T>
5353
where TInterface : class, INumberProperty
5454
where T : class
5555
{
56-
public NumberPropertyDescriptorBase() : base("double") { }
56+
protected NumberPropertyDescriptorBase() : base("double") { }
5757

5858
protected NumberPropertyDescriptorBase(string type) : base(type) { }
5959

60-
NonStringIndexOption? INumberProperty.Index { get; set; }
60+
bool? INumberProperty.Index { get; set; }
6161
double? INumberProperty.Boost { get; set; }
6262
double? INumberProperty.NullValue { get; set; }
6363
bool? INumberProperty.IncludeInAll { get; set; }
@@ -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(bool index) => 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+
}

Diff for: src/Nest/Mapping/Types/Specialized/Ip/IpAttribute.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public class IpAttribute : ElasticsearchPropertyAttributeBase, IIpProperty
66

77
double? IIpProperty.Boost { get; set; }
88
bool? IIpProperty.IncludeInAll { get; set; }
9-
NonStringIndexOption? IIpProperty.Index { get; set; }
9+
bool? IIpProperty.Index { get; set; }
1010
string IIpProperty.NullValue { get; set; }
1111
int? IIpProperty.PrecisionStep { get; set; }
1212

1313
public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } }
1414
public bool IncludeInAll { get { return Self.IncludeInAll.GetValueOrDefault(); } set { Self.IncludeInAll = value; } }
15-
public NonStringIndexOption Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
15+
public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } }
1616
public string NullValue { get { return Self.NullValue; } set { Self.NullValue = value; } }
1717
public int PrecisionStep { get { return Self.PrecisionStep.GetValueOrDefault(); } set { Self.PrecisionStep = value; } }
1818

Diff for: src/Nest/Mapping/Types/Specialized/Ip/IpProperty.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Nest
66
public interface IIpProperty : IProperty
77
{
88
[JsonProperty("index")]
9-
NonStringIndexOption? Index { get; set; }
9+
bool? Index { get; set; }
1010

1111
[JsonProperty("precision_step")]
1212
int? PrecisionStep { get; set; }
@@ -27,7 +27,7 @@ public IpProperty() : base("ip") { }
2727

2828
public double? Boost { get; set; }
2929
public bool? IncludeInAll { get; set; }
30-
public NonStringIndexOption? Index { get; set; }
30+
public bool? Index { get; set; }
3131
public string NullValue { get; set; }
3232
public int? PrecisionStep { get; set; }
3333
}
@@ -36,15 +36,15 @@ public class IpPropertyDescriptor<T>
3636
: PropertyDescriptorBase<IpPropertyDescriptor<T>, IIpProperty, T>, IIpProperty
3737
where T : class
3838
{
39-
NonStringIndexOption? IIpProperty.Index { get; set; }
39+
bool? IIpProperty.Index { get; set; }
4040
int? IIpProperty.PrecisionStep { get; set; }
4141
double? IIpProperty.Boost { get; set; }
4242
string IIpProperty.NullValue { get; set; }
4343
bool? IIpProperty.IncludeInAll { get; set; }
4444

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

47-
public IpPropertyDescriptor<T> Index(NonStringIndexOption? index) => Assign(a => a.Index = index);
47+
public IpPropertyDescriptor<T> Index(bool index) => 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+
}

Diff for: src/Nest/Nest.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@
767767
<Compile Include="Mapping\MetaFields\Source\SourceField.cs" />
768768
<Compile Include="Mapping\MetaFields\Timestamp\TimestampField.cs" />
769769
<Compile Include="Mapping\MetaFields\Ttl\TtlField.cs" />
770-
<Compile Include="Mapping\NonStringIndexOption.cs" />
771770
<Compile Include="Mapping\Norms\Norms.cs" />
772771
<Compile Include="Mapping\Norms\NormsLoading.cs" />
773772
<Compile Include="Mapping\PropertyMapping.cs" />

Diff for: src/Tests/Mapping/Types/Core/Boolean/BooleanMappingTests.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ namespace Tests.Mapping.Types.Core.Boolean
66
public class BooleanTest
77
{
88
[Boolean(
9-
DocValues = false,
10-
IndexName = "myindex",
9+
DocValues = false,
10+
IndexName = "myindex",
1111
Similarity = SimilarityOption.BM25,
12+
Index = false,
1213
Store = true)]
1314
public bool Full { get; set; }
1415

@@ -28,7 +29,8 @@ public class BooleanMappingTests : TypeMappingTestBase<BooleanTest>
2829
doc_values = false,
2930
index_name = "myindex",
3031
similarity = "BM25",
31-
store = true
32+
store = true,
33+
index = false,
3234
},
3335
minimal = new
3436
{
@@ -43,6 +45,7 @@ public class BooleanMappingTests : TypeMappingTestBase<BooleanTest>
4345
.DocValues(false)
4446
.IndexName("myindex")
4547
.Similarity(SimilarityOption.BM25)
48+
.Index(false)
4649
.Store(true)
4750
)
4851
.Boolean(s => s

Diff for: src/Tests/Mapping/Types/Core/Date/DateMappingTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class DateTest
1010
IndexName = "myindex",
1111
Similarity = SimilarityOption.Classic,
1212
Store = true,
13-
Index = NonStringIndexOption.No,
13+
Index = false,
1414
Boost = 1.2,
1515
IncludeInAll = false,
1616
PrecisionStep = 5,
@@ -40,7 +40,7 @@ public class DateMappingTests : TypeMappingTestBase<DateTest>
4040
index_name = "myindex",
4141
similarity = "classic",
4242
store = true,
43-
index = "no",
43+
index = false,
4444
boost = 1.2,
4545
include_in_all = false,
4646
precision_step = 5,
@@ -70,7 +70,7 @@ public class DateMappingTests : TypeMappingTestBase<DateTest>
7070
.IndexName("myindex")
7171
.Similarity(SimilarityOption.Classic)
7272
.Store()
73-
.Index(NonStringIndexOption.No)
73+
.Index(false)
7474
.Boost(1.2)
7575
.IncludeInAll(false)
7676
.PrecisionStep(5)

Diff for: src/Tests/Mapping/Types/Core/Number/NumberMappingTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class NumberTest
1010
IndexName = "myindex",
1111
Similarity = SimilarityOption.Classic,
1212
Store = true,
13-
Index = NonStringIndexOption.No,
13+
Index = false,
1414
Boost = 1.5,
1515
NullValue = 0.0,
1616
IncludeInAll = false,
@@ -61,7 +61,7 @@ public class NumberMappingTests
6161
index_name = "myindex",
6262
similarity = "classic",
6363
store = true,
64-
index = "no",
64+
index = false,
6565
boost = 1.5,
6666
null_value = 0.0,
6767
include_in_all = false,
@@ -131,7 +131,7 @@ public class NumberMappingTests
131131
.IndexName("myindex")
132132
.Similarity(SimilarityOption.Classic)
133133
.Store()
134-
.Index(NonStringIndexOption.No)
134+
.Index(false)
135135
.Boost(1.5)
136136
.NullValue(0.0)
137137
.IncludeInAll(false)

0 commit comments

Comments
 (0)