forked from elastic/elasticsearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoutingFieldMapping.cs
51 lines (41 loc) · 1.12 KB
/
RoutingFieldMapping.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using Newtonsoft.Json;
using System.Linq.Expressions;
using Nest.Resolvers.Converters;
namespace Nest
{
[JsonConverter(typeof(ReadAsTypeConverter<RoutingFieldMapping>))]
public interface IRoutingFieldMapping : ISpecialField
{
[JsonProperty("required")]
bool? Required { get; set; }
[JsonProperty("path")]
PropertyPathMarker Path { get; set; }
}
public class RoutingFieldMapping : IRoutingFieldMapping
{
public bool? Required { get; set; }
public PropertyPathMarker Path { get; set; }
}
public class RoutingFieldMappingDescriptor<T> : IRoutingFieldMapping
{
private IRoutingFieldMapping Self { get { return this; } }
bool? IRoutingFieldMapping.Required { get; set;}
PropertyPathMarker IRoutingFieldMapping.Path { get; set; }
public RoutingFieldMappingDescriptor<T> Required(bool required = true)
{
Self.Required = required;
return this;
}
public RoutingFieldMappingDescriptor<T> Path(string path)
{
Self.Path = path;
return this;
}
public RoutingFieldMappingDescriptor<T> Path(Expression<Func<T, object>> objectPath)
{
Self.Path = objectPath;
return this;
}
}
}