Skip to content

Commit c4e998a

Browse files
authored
Change GenericProperty.Index to bool? (#3224)
This commit changes the implementation of GenericProperty.Index to use bool? in line with other properties. Remove FieldIndexOption. Fixes #3103
1 parent 8f6e81d commit c4e998a

File tree

6 files changed

+15
-34
lines changed

6 files changed

+15
-34
lines changed

.paket/Paket.Restore.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
<!-- Because ReadAllText is slow on osx/linux, try to find shasum and awk -->
5050
<PropertyGroup>
51-
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketRestoreCacheFile) | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
52-
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketLockFilePath) | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
51+
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketRestoreCacheFile)" | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
52+
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketLockFilePath)" | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
5353
</PropertyGroup>
5454

5555
<!-- If shasum and awk exist get the hashes -->

src/Nest/Mapping/FieldIndexOption.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Nest/Mapping/Types/Specialized/Generic/GenericProperty.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Nest
1212
public interface IGenericProperty : IDocValuesProperty
1313
{
1414
[JsonProperty("index")]
15-
FieldIndexOption? Index { get; set; }
15+
bool? Index { get; set; }
1616

1717
[JsonProperty("term_vector")]
1818
TermVectorOption? TermVector { get; set; }
@@ -60,7 +60,7 @@ public class GenericProperty : DocValuesPropertyBase, IGenericProperty
6060
public int? IgnoreAbove { get; set; }
6161
public int? PositionIncrementGap { get; set; }
6262
public IStringFielddata Fielddata { get; set; }
63-
public FieldIndexOption? Index { get; set; }
63+
public bool? Index { get; set; }
6464
public string NullValue { get; set; }
6565
public bool? Norms { get; set; }
6666
public IndexOptions? IndexOptions { get; set; }
@@ -82,7 +82,7 @@ public class GenericPropertyDescriptor<T>
8282
: DocValuesPropertyDescriptorBase<GenericPropertyDescriptor<T>, IGenericProperty, T>, IGenericProperty
8383
where T : class
8484
{
85-
FieldIndexOption? IGenericProperty.Index { get; set; }
85+
bool? IGenericProperty.Index { get; set; }
8686
TermVectorOption? IGenericProperty.TermVector { get; set; }
8787
double? IGenericProperty.Boost { get; set; }
8888
string IGenericProperty.NullValue { get; set; }
@@ -98,14 +98,12 @@ public class GenericPropertyDescriptor<T>
9898

9999
public GenericPropertyDescriptor<T> Type(string type) => Assign(a => this.TypeOverride = type);
100100

101-
public GenericPropertyDescriptor<T> Index(FieldIndexOption? index = FieldIndexOption.NotAnalyzed) => Assign(a => a.Index = index);
101+
public GenericPropertyDescriptor<T> Index(bool? index = true) => Assign(a => a.Index = index);
102102

103103
public GenericPropertyDescriptor<T> Boost(double? boost) => Assign(a => a.Boost = boost);
104104

105105
public GenericPropertyDescriptor<T> NullValue(string nullValue) => Assign(a => a.NullValue = nullValue);
106106

107-
public GenericPropertyDescriptor<T> NotAnalyzed() => Index(FieldIndexOption.NotAnalyzed);
108-
109107
public GenericPropertyDescriptor<T> TermVector(TermVectorOption? termVector) => Assign(a => a.TermVector = termVector);
110108

111109
public GenericPropertyDescriptor<T> IndexOptions(IndexOptions? indexOptions) => Assign(a => a.IndexOptions = indexOptions);

src/Tests/IndexModules/IndexSettings/Settings/TypedIndexSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Usage : PromiseUsageTestBase<IIndexSettings, IndexSettingsDescripto
1717
{"any.setting", "can be set"},
1818
{"doubles", 1.1},
1919
{"bools", false},
20-
{"enums", "analyzed"},
20+
{"enums", "offsets"},
2121
{"index.number_of_replicas", 2},
2222
{"index.auto_expand_replicas", "1-3" },
2323
{"index.refresh_interval", -1 },
@@ -42,7 +42,7 @@ public class Usage : PromiseUsageTestBase<IIndexSettings, IndexSettingsDescripto
4242
.Setting("any.setting", "can be set")
4343
.Setting("doubles", 1.1)
4444
.Setting("bools", false)
45-
.Setting("enums", FieldIndexOption.Analyzed)
45+
.Setting("enums", IndexOptions.Offsets)
4646
.NumberOfShards(1)
4747
.NumberOfReplicas(2)
4848
.AutoExpandReplicas("1-3")
@@ -67,7 +67,7 @@ public class Usage : PromiseUsageTestBase<IIndexSettings, IndexSettingsDescripto
6767
{ "any.setting", "can be set" },
6868
{ "doubles", 1.1 },
6969
{ "bools", false },
70-
{ "enums", FieldIndexOption.Analyzed },
70+
{ "enums", IndexOptions.Offsets },
7171
})
7272
{
7373
NumberOfShards = 1,

src/Tests/Indices/IndexSettings/IndexTemplates/PutIndexTemplate/PutIndexTemplateApiTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected override LazyResponses ClientUsage() => Calls(
4949
match_mapping_type = "*",
5050
mapping = new
5151
{
52-
index = "no"
52+
index = false
5353
}
5454
}
5555
}
@@ -74,7 +74,7 @@ protected override LazyResponses ClientUsage() => Calls(
7474
.MatchMappingType("*")
7575
.Mapping(mm => mm
7676
.Generic(g => g
77-
.Index(FieldIndexOption.No)
77+
.Index(false)
7878
)
7979
)
8080
)
@@ -106,7 +106,7 @@ protected override LazyResponses ClientUsage() => Calls(
106106
MatchMappingType = "*",
107107
Mapping = new GenericProperty
108108
{
109-
Index = FieldIndexOption.No
109+
Index = false
110110
}
111111
}
112112
}

src/Tests/Mapping/Types/Specialized/Generic/GenericPropertyTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public class GenericPropertyTests : SingleMappingPropertyTestsBase
1010
private const string GenericType = "{dynamic_type}";
1111
public GenericPropertyTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
1212

13-
protected override object SingleMappingJson { get; } = new {index = "no", type= GenericType};
13+
protected override object SingleMappingJson { get; } = new {index = false, type= GenericType};
1414

1515
protected override Func<SingleMappingSelector<object>, IProperty> FluentSingleMapping => m => m
1616
.Generic(g => g
1717
.Type(GenericType)
18-
.Index(FieldIndexOption.No)
18+
.Index(false)
1919
);
2020

2121
protected override IProperty InitializerSingleMapping { get; } = new GenericProperty
2222
{
2323
Type = GenericType,
24-
Index = FieldIndexOption.No
24+
Index = false
2525
};
2626
}
2727
}

0 commit comments

Comments
 (0)