4
4
5
5
namespace Nest
6
6
{
7
+ /// <summary>
8
+ /// An operation to define the calculation of
9
+ /// term vectors when using Multi termvectors API
10
+ /// </summary>
7
11
public interface IMultiTermVectorOperation
8
12
{
13
+ /// <summary>
14
+ /// The index in which the document resides
15
+ /// </summary>
9
16
[ JsonProperty ( "_index" ) ]
10
17
IndexName Index { get ; set ; }
18
+
19
+ /// <summary>
20
+ /// The type of the document
21
+ /// </summary>
11
22
[ JsonProperty ( "_type" ) ]
12
23
TypeName Type { get ; set ; }
24
+
25
+ /// <summary>
26
+ /// The id of the document
27
+ /// </summary>
13
28
[ JsonProperty ( "_id" ) ]
14
29
Id Id { get ; set ; }
30
+
31
+ /// <summary>
32
+ /// A document not indexed in Elasticsearch,
33
+ /// to generate term vectors for
34
+ /// </summary>
15
35
[ JsonProperty ( "doc" ) ]
16
36
[ JsonConverter ( typeof ( SourceConverter ) ) ]
17
37
object Document { get ; set ; }
38
+
39
+ /// <summary>
40
+ /// The document field to generate term
41
+ /// vectors for
42
+ /// </summary>
18
43
[ JsonProperty ( "fields" ) ]
44
+ // TODO: Rename to Fields in 7.x
19
45
Fields StoredFields { get ; set ; }
46
+
47
+ /// <summary>
48
+ /// Whether to include the start and end offsets.
49
+ /// Default is <c>true</c>.
50
+ /// </summary>
20
51
[ JsonProperty ( "offsets" ) ]
21
52
bool ? Offsets { get ; set ; }
53
+
54
+ /// <summary>
55
+ /// Whether to include the term payloads as
56
+ /// base64 encoded bytes. Default is <c>true</c>
57
+ /// </summary>
22
58
[ JsonProperty ( "payloads" ) ]
23
59
bool ? Payloads { get ; set ; }
60
+
61
+ /// <summary>
62
+ /// Whether to include the term positions.
63
+ /// Default is <c>true</c>
64
+ /// </summary>
24
65
[ JsonProperty ( "positions" ) ]
25
66
bool ? Positions { get ; set ; }
67
+
68
+ /// <summary>
69
+ /// Whether to include term statistics. When set to <c>true</c>,
70
+ /// <para />- total term frequency (how often a term occurs in all documents)
71
+ /// <para />- document frequency (the number of documents containing the current term)
72
+ /// <para />will be returned. Default is <c>false</c> since
73
+ /// term statistics can have a large performance impact.
74
+ /// </summary>
26
75
[ JsonProperty ( "term_statistics" ) ]
27
76
bool ? TermStatistics { get ; set ; }
77
+
78
+ /// <summary>
79
+ /// Whether to include field statistics. When set to <c>false</c>,
80
+ /// <para />- document count (how many documents contain this field)
81
+ /// <para />- sum of document frequencies (the sum of document frequencies for all terms in this field)
82
+ /// <para />- sum of total term frequencies (the sum of total term frequencies of each term in this field)
83
+ /// <para />will be omitted. Default is <c>true</c>.
84
+ /// </summary>
28
85
[ JsonProperty ( "field_statistics" ) ]
29
86
bool ? FieldStatistics { get ; set ; }
87
+
88
+ /// <summary>
89
+ /// Filter terms based on their tf-idf scores.
90
+ /// This can be useful in order find out a good characteristic
91
+ /// vector of a document.
92
+ /// </summary>
30
93
[ JsonProperty ( "filter" ) ]
31
94
ITermVectorFilter Filter { get ; set ; }
95
+
96
+ /// <summary>
97
+ /// The version number
98
+ /// </summary>
32
99
[ JsonProperty ( "version" ) ]
33
100
long ? Version { get ; set ; }
101
+
102
+ /// <summary>
103
+ /// The type of version
104
+ /// </summary>
34
105
[ JsonProperty ( "version_type" ) ]
35
106
VersionType ? VersionType { get ; set ; }
107
+
108
+ /// <summary>
109
+ /// When requesting term vectors for <see cref="Document"/>,
110
+ /// a shard to get the statistics from is randomly selected.
111
+ /// Use <see cref="Routing"/> only to hit a particular shard.
112
+ /// </summary>
36
113
[ JsonProperty ( "routing" ) ]
37
114
Routing Routing { get ; set ; }
38
115
}
39
116
117
+ /// <inheritdoc />
40
118
public class MultiTermVectorOperation < T > : IMultiTermVectorOperation
41
119
where T : class
42
120
{
121
+ private Routing _routing ;
43
122
44
123
public MultiTermVectorOperation ( Id id )
45
124
{
@@ -48,31 +127,46 @@ public MultiTermVectorOperation(Id id)
48
127
this . Type = typeof ( T ) ;
49
128
}
50
129
130
+ /// <inheritdoc />
51
131
public IndexName Index { get ; set ; }
132
+ /// <inheritdoc />
52
133
public TypeName Type { get ; set ; }
134
+ /// <inheritdoc />
53
135
public Id Id { get ; set ; }
136
+ /// <inheritdoc />
54
137
public object Document { get ; set ; }
138
+ /// <inheritdoc />
55
139
public Fields StoredFields { get ; set ; }
140
+ /// <inheritdoc />
56
141
public bool ? Offsets { get ; set ; }
142
+ /// <inheritdoc />
57
143
public bool ? Payloads { get ; set ; }
144
+ /// <inheritdoc />
58
145
public bool ? Positions { get ; set ; }
146
+ /// <inheritdoc />
59
147
public bool ? TermStatistics { get ; set ; }
148
+ /// <inheritdoc />
60
149
public bool ? FieldStatistics { get ; set ; }
150
+ /// <inheritdoc />
61
151
public ITermVectorFilter Filter { get ; set ; }
152
+ /// <inheritdoc />
62
153
public long ? Version { get ; set ; }
154
+ /// <inheritdoc />
63
155
public VersionType ? VersionType { get ; set ; }
64
-
65
- private Routing _routing ;
156
+ /// <inheritdoc />
66
157
public Routing Routing
67
158
{
68
159
get => _routing ?? ( Document == null ? null : new Routing ( Document ) ) ;
69
160
set => _routing = value ;
70
161
}
71
162
}
72
163
164
+ /// <inheritdoc cref="IMultiTermVectorOperation"/>
73
165
public class MultiTermVectorOperationDescriptor < T > : DescriptorBase < MultiTermVectorOperationDescriptor < T > , IMultiTermVectorOperation > , IMultiTermVectorOperation
74
166
where T : class
75
167
{
168
+ private Routing _routing ;
169
+
76
170
IndexName IMultiTermVectorOperation . Index { get ; set ; } = typeof ( T ) ;
77
171
TypeName IMultiTermVectorOperation . Type { get ; set ; } = typeof ( T ) ;
78
172
Id IMultiTermVectorOperation . Id { get ; set ; }
@@ -86,40 +180,59 @@ public class MultiTermVectorOperationDescriptor<T> : DescriptorBase<MultiTermVec
86
180
ITermVectorFilter IMultiTermVectorOperation . Filter { get ; set ; }
87
181
long ? IMultiTermVectorOperation . Version { get ; set ; }
88
182
VersionType ? IMultiTermVectorOperation . VersionType { get ; set ; }
89
-
90
- private Routing _routing ;
91
183
Routing IMultiTermVectorOperation . Routing
92
184
{
93
185
get => _routing ?? ( Self . Document == null ? null : new Routing ( Self . Document ) ) ;
94
186
set => _routing = value ;
95
187
}
96
188
189
+ /// <inheritdoc cref="IMultiTermVectorOperation.StoredFields"/>
190
+ // TODO: Rename to Fields in 7.x
97
191
public MultiTermVectorOperationDescriptor < T > StoredFields ( Func < FieldsDescriptor < T > , IPromise < Fields > > fields ) =>
98
192
Assign ( a => a . StoredFields = fields ? . Invoke ( new FieldsDescriptor < T > ( ) ) ? . Value ) ;
99
193
194
+ /// <inheritdoc cref="IMultiTermVectorOperation.StoredFields"/>
195
+ // TODO: Rename to Fields in 7.x
100
196
public MultiTermVectorOperationDescriptor < T > StoredFields ( Fields fields ) => Assign ( a => a . StoredFields = fields ) ;
101
197
102
- public MultiTermVectorOperationDescriptor < T > Id ( Id id ) => Assign ( a=> a . Id = id ) ;
198
+ /// <inheritdoc cref="IMultiTermVectorOperation.Id"/>
199
+ public MultiTermVectorOperationDescriptor < T > Id ( Id id ) => Assign ( a=> a . Id = id ) ;
200
+
201
+ /// <inheritdoc cref="IMultiTermVectorOperation.Index"/>
202
+ public MultiTermVectorOperationDescriptor < T > Index ( IndexName index ) => Assign ( a => a . Index = index ) ;
203
+
204
+ /// <inheritdoc cref="IMultiTermVectorOperation.Type"/>
205
+ public MultiTermVectorOperationDescriptor < T > Type ( TypeName type ) => Assign ( a=> a . Type = type ) ;
103
206
207
+ /// <inheritdoc cref="IMultiTermVectorOperation.Document"/>
104
208
public MultiTermVectorOperationDescriptor < T > Document ( T document ) => Assign ( a => a . Document = document ) ;
105
209
210
+ /// <inheritdoc cref="IMultiTermVectorOperation.Offsets"/>
106
211
public MultiTermVectorOperationDescriptor < T > Offsets ( bool ? offsets = true ) => Assign ( a => a . Offsets = offsets ) ;
107
212
213
+ /// <inheritdoc cref="IMultiTermVectorOperation.Payloads"/>
108
214
public MultiTermVectorOperationDescriptor < T > Payloads ( bool ? payloads = true ) => Assign ( a => a . Payloads = payloads ) ;
109
215
216
+ /// <inheritdoc cref="IMultiTermVectorOperation.Positions"/>
110
217
public MultiTermVectorOperationDescriptor < T > Positions ( bool ? positions = true ) => Assign ( a => a . Positions = positions ) ;
111
218
219
+ /// <inheritdoc cref="IMultiTermVectorOperation.TermStatistics"/>
112
220
public MultiTermVectorOperationDescriptor < T > TermStatistics ( bool ? termStatistics = true ) => Assign ( a => a . TermStatistics = termStatistics ) ;
113
221
222
+ /// <inheritdoc cref="IMultiTermVectorOperation.FieldStatistics"/>
114
223
public MultiTermVectorOperationDescriptor < T > FieldStatistics ( bool ? fieldStatistics = true ) => Assign ( a => a . FieldStatistics = fieldStatistics ) ;
115
224
225
+ /// <inheritdoc cref="IMultiTermVectorOperation.Filter"/>
116
226
public MultiTermVectorOperationDescriptor < T > Filter ( Func < TermVectorFilterDescriptor , ITermVectorFilter > filterSelector ) =>
117
227
Assign ( a => a . Filter = filterSelector ? . Invoke ( new TermVectorFilterDescriptor ( ) ) ) ;
118
228
229
+ /// <inheritdoc cref="IMultiTermVectorOperation.Version"/>
119
230
public MultiTermVectorOperationDescriptor < T > Version ( long ? version ) => Assign ( a => a . Version = version ) ;
120
231
232
+ /// <inheritdoc cref="IMultiTermVectorOperation.VersionType"/>
121
233
public MultiTermVectorOperationDescriptor < T > VersionType ( VersionType ? versionType ) => Assign ( a => a . VersionType = versionType ) ;
122
234
235
+ /// <inheritdoc cref="IMultiTermVectorOperation.Routing"/>
123
236
public MultiTermVectorOperationDescriptor < T > Routing ( Routing routing ) => Assign ( a => a . Routing = routing ) ;
124
237
}
125
238
}
0 commit comments