Skip to content

Commit 5e4f161

Browse files
committed
Merge branch 'fix/specialfields' into develop
2 parents 6c2631b + af01e33 commit 5e4f161

36 files changed

+398
-269
lines changed

Diff for: src/Nest/DSL/PutMappingDescriptor.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ public PutMappingDescriptor<T> AllField(Func<AllFieldMappingDescriptor, AllField
168168

169169
public PutMappingDescriptor<T> DisableSizeField(bool disabled = true)
170170
{
171-
Self.Mapping.SizeFieldMapping = new SizeFieldMapping().SetDisabled(disabled);
171+
Self.Mapping.SizeFieldMapping = new SizeFieldMapping { Enabled = !disabled };
172172
return this;
173173
}
174174

175175
public PutMappingDescriptor<T> DisableIndexField(bool disabled = true)
176176
{
177-
Self.Mapping.IndexFieldMapping = new IndexFieldMapping().SetDisabled(disabled);
177+
Self.Mapping.IndexFieldMapping = new IndexFieldMapping { Enabled = !disabled };
178178
return this;
179179
}
180180

@@ -204,54 +204,54 @@ public PutMappingDescriptor<T> NumericDetection(bool detect = true)
204204
Self.Mapping.NumericDetection = detect;
205205
return this;
206206
}
207-
public PutMappingDescriptor<T> IdField(Func<IdFieldMapping, IdFieldMapping> idMapper)
207+
public PutMappingDescriptor<T> IdField(Func<IdFieldMappingDescriptor, IIdFieldMapping> idMapper)
208208
{
209209
idMapper.ThrowIfNull("idMapper");
210-
Self.Mapping.IdFieldMapping = idMapper(new IdFieldMapping());
210+
Self.Mapping.IdFieldMappingDescriptor = idMapper(new IdFieldMappingDescriptor());
211211
return this;
212212
}
213213

214-
public PutMappingDescriptor<T> TypeField(Func<TypeFieldMapping, TypeFieldMapping> typeMapper)
214+
public PutMappingDescriptor<T> TypeField(Func<TypeFieldMappingDescriptor, ITypeFieldMapping> typeMapper)
215215
{
216216
typeMapper.ThrowIfNull("typeMapper");
217-
Self.Mapping.TypeFieldMapping = typeMapper(new TypeFieldMapping());
217+
Self.Mapping.TypeFieldMappingDescriptor = typeMapper(new TypeFieldMappingDescriptor());
218218
return this;
219219
}
220-
public PutMappingDescriptor<T> SourceField(Func<SourceFieldMapping, SourceFieldMapping> sourceMapper)
220+
public PutMappingDescriptor<T> SourceField(Func<SourceFieldMappingDescriptor, ISourceFieldMapping> sourceMapper)
221221
{
222222
sourceMapper.ThrowIfNull("sourceMapper");
223-
Self.Mapping.SourceFieldMapping = sourceMapper(new SourceFieldMapping());
223+
Self.Mapping.SourceFieldMappingDescriptor = sourceMapper(new SourceFieldMappingDescriptor());
224224
return this;
225225
}
226226

227-
public PutMappingDescriptor<T> AnalyzerField(Func<AnalyzerFieldMapping<T>, AnalyzerFieldMapping> analyzeMapper)
227+
public PutMappingDescriptor<T> AnalyzerField(Func<AnalyzerFieldMappingDescriptor<T>, IAnalyzerFieldMapping> analyzeMapper)
228228
{
229229
analyzeMapper.ThrowIfNull("analyzeMapper");
230-
Self.Mapping.AnalyzerFieldMapping = analyzeMapper(new AnalyzerFieldMapping<T>());
230+
Self.Mapping.AnalyzerFieldMapping = analyzeMapper(new AnalyzerFieldMappingDescriptor<T>());
231231
return this;
232232
}
233-
public PutMappingDescriptor<T> BoostField(Func<BoostFieldMapping<T>, BoostFieldMapping> boostMapper)
233+
public PutMappingDescriptor<T> BoostField(Func<BoostFieldMappingDescriptor<T>, IBoostFieldMapping> boostMapper)
234234
{
235235
boostMapper.ThrowIfNull("boostMapper");
236-
Self.Mapping.BoostFieldMapping = boostMapper(new BoostFieldMapping<T>());
236+
Self.Mapping.BoostFieldMapping = boostMapper(new BoostFieldMappingDescriptor<T>());
237237
return this;
238238
}
239-
public PutMappingDescriptor<T> RoutingField(Func<RoutingFieldMapping<T>, RoutingFieldMapping> routingMapper)
239+
public PutMappingDescriptor<T> RoutingField(Func<RoutingFieldMappingDescriptor<T>, IRoutingFieldMapping> routingMapper)
240240
{
241241
routingMapper.ThrowIfNull("routingMapper");
242-
Self.Mapping.RoutingFieldMapping = routingMapper(new RoutingFieldMapping<T>());
242+
Self.Mapping.RoutingFieldMapping = routingMapper(new RoutingFieldMappingDescriptor<T>());
243243
return this;
244244
}
245-
public PutMappingDescriptor<T> TimestampField(Func<TimestampFieldMapping<T>, TimestampFieldMapping> timestampMapper)
245+
public PutMappingDescriptor<T> TimestampField(Func<TimestampFieldMappingDescriptor<T>, ITimestampFieldMapping> timestampMapper)
246246
{
247247
timestampMapper.ThrowIfNull("timestampMapper");
248-
Self.Mapping.TimestampFieldMapping = timestampMapper(new TimestampFieldMapping<T>());
248+
Self.Mapping.TimestampFieldMapping = timestampMapper(new TimestampFieldMappingDescriptor<T>());
249249
return this;
250250
}
251-
public PutMappingDescriptor<T> TtlField(Func<TtlFieldMapping, TtlFieldMapping> ttlFieldMapper)
251+
public PutMappingDescriptor<T> TtlField(Func<TtlFieldMappingDescriptor, ITtlFieldMapping> ttlFieldMapper)
252252
{
253253
ttlFieldMapper.ThrowIfNull("ttlFieldMapper");
254-
Self.Mapping.TtlFieldMapping = ttlFieldMapper(new TtlFieldMapping());
254+
Self.Mapping.TtlFieldMappingDescriptor = ttlFieldMapper(new TtlFieldMappingDescriptor());
255255
return this;
256256
}
257257
public PutMappingDescriptor<T> Properties(Func<PropertiesDescriptor<T>, PropertiesDescriptor<T>> propertiesSelector)

Diff for: src/Nest/Domain/Mapping/SpecialFields/AllFieldMapping.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Nest
55
{
66
[JsonConverter(typeof(ReadAsTypeConverter<AllFieldMapping>))]
7-
public interface IAllFieldMapping
7+
public interface IAllFieldMapping : ISpecialField
88
{
99
[JsonProperty("enabled")]
1010
bool? Enabled { get; set; }

Diff for: src/Nest/Domain/Mapping/SpecialFields/AnalyzerFieldMapping.cs

+23-16
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,44 @@
55

66
namespace Nest
77
{
8-
public class AnalyzerFieldMapping
8+
public interface IAnalyzerFieldMapping : ISpecialField
99
{
10-
public AnalyzerFieldMapping()
11-
{
12-
this.Index = true;
13-
}
14-
1510
[JsonProperty("index"), JsonConverter(typeof(YesNoBoolConverter))]
16-
public bool? Index { get; internal set; }
11+
bool? Index { get; set; }
1712

1813
[JsonProperty("path")]
19-
public PropertyPathMarker Path { get; internal set; }
14+
PropertyPathMarker Path { get; set; }
15+
}
16+
17+
public class AnalyzerFieldMapping : IAnalyzerFieldMapping
18+
{
19+
public bool? Index { get; set; }
20+
21+
public PropertyPathMarker Path { get; set; }
2022
}
2123

2224

23-
public class AnalyzerFieldMapping<T> : AnalyzerFieldMapping
25+
public class AnalyzerFieldMappingDescriptor<T> : IAnalyzerFieldMapping
2426
{
25-
public AnalyzerFieldMapping<T> SetIndexed(bool indexed = true)
27+
private IAnalyzerFieldMapping Self { get { return this; } }
28+
29+
bool? IAnalyzerFieldMapping.Index { get; set; }
30+
31+
PropertyPathMarker IAnalyzerFieldMapping.Path { get; set; }
32+
33+
public AnalyzerFieldMappingDescriptor<T> Index(bool indexed = true)
2634
{
27-
this.Index = indexed;
35+
Self.Index = indexed;
2836
return this;
2937
}
30-
public AnalyzerFieldMapping<T> SetPath(string path)
38+
public AnalyzerFieldMappingDescriptor<T> Path(string path)
3139
{
32-
this.Path = path;
40+
Self.Path = path;
3341
return this;
3442
}
35-
public AnalyzerFieldMapping<T> SetPath(Expression<Func<T, object>> objectPath)
43+
public AnalyzerFieldMappingDescriptor<T> Path(Expression<Func<T, object>> objectPath)
3644
{
37-
objectPath.ThrowIfNull("objectPath");
38-
this.Path = objectPath;
45+
Self.Path = objectPath;
3946
return this;
4047
}
4148
}

Diff for: src/Nest/Domain/Mapping/SpecialFields/BoostFieldMapping.cs

+24-11
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,46 @@
44

55
namespace Nest
66
{
7-
public class BoostFieldMapping
7+
public interface IBoostFieldMapping : ISpecialField
88
{
99
[JsonProperty("name")]
10-
public PropertyNameMarker Name { get; internal set; }
10+
PropertyNameMarker Name { get; set; }
1111

1212
[JsonProperty("null_value")]
13-
public double NullValue { get; internal set; }
13+
double NullValue { get; set; }
14+
}
15+
16+
public class BoostFieldMapping : IBoostFieldMapping
17+
{
18+
public PropertyNameMarker Name { get; set; }
19+
20+
public double NullValue { get; set; }
1421
}
1522

1623

17-
public class BoostFieldMapping<T> : BoostFieldMapping
24+
public class BoostFieldMappingDescriptor<T> : IBoostFieldMapping
1825
{
19-
public BoostFieldMapping<T> SetNullValue(double boost)
26+
private IBoostFieldMapping Self { get { return this; } }
27+
28+
PropertyNameMarker IBoostFieldMapping.Name { get; set; }
29+
30+
double IBoostFieldMapping.NullValue { get; set; }
31+
32+
public BoostFieldMappingDescriptor<T> NullValue(double boost)
2033
{
21-
this.NullValue = boost;
34+
Self.NullValue = boost;
2235
return this;
2336
}
24-
public BoostFieldMapping<T> SetName(string path)
37+
public BoostFieldMappingDescriptor<T> Name(string path)
2538
{
26-
this.Name = path;
39+
Self.Name = path;
2740
return this;
2841
}
29-
public BoostFieldMapping<T> SetName(Expression<Func<T, object>> objectPath)
42+
public BoostFieldMappingDescriptor<T> Name(Expression<Func<T, object>> objectPath)
3043
{
31-
objectPath.ThrowIfNull("objectPath");
32-
this.Name = objectPath;
44+
Self.Name = objectPath;
3345
return this;
3446
}
47+
3548
}
3649
}

Diff for: src/Nest/Domain/Mapping/SpecialFields/DynamicTemplate.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ namespace Nest
66
public class DynamicTemplate
77
{
88
[JsonProperty("match")]
9-
public string Match { get; internal set; }
9+
public string Match { get; set; }
1010

1111
[JsonProperty("unmatch")]
12-
public string Unmatch { get; internal set; }
12+
public string Unmatch { get; set; }
1313

1414
[JsonProperty("match_mapping_type")]
15-
public string MatchMappingType { get; internal set; }
15+
public string MatchMappingType { get; set; }
1616

1717
[JsonProperty("path_match")]
18-
public string PathMatch { get; internal set; }
18+
public string PathMatch { get; set; }
1919

2020
[JsonProperty("path_unmatch")]
21-
public string PathUnmatch { get; internal set; }
21+
public string PathUnmatch { get; set; }
2222

2323
[JsonProperty("mapping"), JsonConverter(typeof(ElasticTypeConverter))]
24-
public IElasticType Mapping { get; internal set; }
24+
public IElasticType Mapping { get; set; }
2525

2626
}
2727
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Nest
2+
{
3+
public interface ISpecialField
4+
{
5+
6+
}
7+
}

Diff for: src/Nest/Domain/Mapping/SpecialFields/IdFieldMapping.cs

+34-17
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,52 @@
22

33
namespace Nest
44
{
5-
public class IdFieldMapping
6-
{
7-
public IdFieldMapping()
8-
{
9-
}
10-
11-
[JsonProperty("path")]
12-
public string Path { get; internal set; }
5+
public interface IIdFieldMapping : ISpecialField
6+
{
7+
[JsonProperty("path")]
8+
string Path { get; set; }
139

1410
[JsonProperty("index")]
15-
public string Index { get; internal set; }
11+
string Index { get; set; }
1612

1713
[JsonProperty("store")]
18-
public bool? Store { get; internal set; }
14+
bool? Store { get; set; }
15+
}
16+
17+
public class IdFieldMapping : IIdFieldMapping
18+
{
19+
public string Path { get; set; }
20+
21+
public string Index { get; set;}
22+
23+
public bool? Store { get; set;}
24+
}
25+
26+
27+
public class IdFieldMappingDescriptor : IIdFieldMapping
28+
{
29+
private IIdFieldMapping Self { get { return this; } }
30+
31+
string IIdFieldMapping.Path { get; set; }
32+
33+
string IIdFieldMapping.Index { get; set; }
34+
35+
bool? IIdFieldMapping.Store { get; set; }
1936

20-
public IdFieldMapping SetPath(string path)
37+
public IdFieldMappingDescriptor Path(string path)
2138
{
22-
this.Path = path;
39+
Self.Path = path;
2340
return this;
2441
}
25-
public IdFieldMapping SetIndex(string index)
42+
public IdFieldMappingDescriptor Index(string index)
2643
{
27-
this.Index = index;
44+
Self.Index = index;
2845
return this;
2946
}
30-
public IdFieldMapping SetStored(bool stored = true)
47+
public IdFieldMappingDescriptor Store(bool stored = true)
3148
{
32-
this.Store = stored;
49+
Self.Store = stored;
3350
return this;
3451
}
35-
}
52+
}
3653
}

Diff for: src/Nest/Domain/Mapping/SpecialFields/IndexFieldMapping.cs

+18-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22

33
namespace Nest
44
{
5-
public class IndexFieldMapping
6-
{
7-
public IndexFieldMapping()
8-
{
9-
10-
}
11-
5+
public interface IIndexFieldMapping : ISpecialField
6+
{
127
[JsonProperty("enabled")]
13-
public bool Enabled { get; internal set; }
8+
bool? Enabled { get; set; }
9+
}
10+
11+
public class IndexFieldMapping : IIndexFieldMapping
12+
{
13+
public bool? Enabled { get; set; }
14+
}
15+
16+
public class IndexFieldMappingDescriptor : IIndexFieldMapping
17+
{
18+
private IIndexFieldMapping Self { get { return this; } }
19+
20+
bool? IIndexFieldMapping.Enabled { get; set; }
1421

15-
public IndexFieldMapping SetDisabled(bool disabled = true)
22+
public IndexFieldMappingDescriptor Enabled(bool enabled = true)
1623
{
17-
this.Enabled = !disabled;
24+
Self.Enabled = enabled;
1825
return this;
1926
}
20-
}
27+
}
2128
}

0 commit comments

Comments
 (0)