-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathBulkCreateDescriptor.cs
125 lines (106 loc) · 2.74 KB
/
BulkCreateDescriptor.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Globalization;
using Nest.Resolvers;
using Elasticsearch.Net;
namespace Nest
{
public class BulkCreateDescriptor<T> : BaseBulkOperation
where T : class
{
internal override Type _ClrType { get { return typeof(T); } }
internal override string _Operation { get { return "create"; } }
internal override object _Object { get; set; }
internal override string GetIdForObject(ElasticInferrer inferrer)
{
if (!this._Id.IsNullOrEmpty())
return this._Id;
return inferrer.Id((T)_Object);
}
/// <summary>
/// Manually set the index, default to the default index or the fixed index set on the bulk operation
/// </summary>
public BulkCreateDescriptor<T> Index(string index)
{
index.ThrowIfNullOrEmpty("indices");
this._Index = index;
return this;
}
/// <summary>
/// Manualy set the type to get the object from, default to whatever
/// T will be inferred to if not passed or the fixed type set on the parent bulk operation
/// </summary>
public BulkCreateDescriptor<T> Type(string type)
{
type.ThrowIfNullOrEmpty("type");
this._Type = type;
return this;
}
/// <summary>
/// Manually set the type of which a typename will be inferred
/// </summary>
public BulkCreateDescriptor<T> Type(Type type)
{
type.ThrowIfNull("type");
this._Type = type;
return this;
}
/// <summary>
/// Manually set the id for the newly created object
/// </summary>
public BulkCreateDescriptor<T> Id(long id)
{
return this.Id(id.ToString(CultureInfo.InvariantCulture));
}
/// <summary>
/// Manually set the id for the newly created object
/// </summary>
public BulkCreateDescriptor<T> Id(string id)
{
this._Id = id;
return this;
}
/// <summary>
/// The object to update, if id is not manually set it will be inferred from the object
/// </summary>
public BulkCreateDescriptor<T> Object(T @object)
{
this._Object = @object;
return this;
}
public BulkCreateDescriptor<T> Version(string version)
{
this._Version = version;
return this;
}
public BulkCreateDescriptor<T> VersionType(string versionType)
{
this._VersionType = versionType;
return this;
}
public BulkCreateDescriptor<T> VersionType(VersionTypeOptions versionType)
{
this._VersionType = versionType.GetStringValue();
return this;
}
public BulkCreateDescriptor<T> Routing(string routing)
{
this._Routing = routing;
return this;
}
public BulkCreateDescriptor<T> Parent(string parent)
{
this._Parent = parent;
return this;
}
public BulkCreateDescriptor<T> Timestamp(long timestamp)
{
this._Timestamp = timestamp;
return this;
}
public BulkCreateDescriptor<T> Ttl(string ttl)
{
this._Ttl = ttl;
return this;
}
}
}