44
55namespace Nest
66{
7+ /// <summary>
8+ /// An operation to define the calculation of
9+ /// term vectors when using Multi termvectors API
10+ /// </summary>
711 public interface IMultiTermVectorOperation
812 {
13+ /// <summary>
14+ /// The index in which the document resides
15+ /// </summary>
916 [ JsonProperty ( "_index" ) ]
1017 IndexName Index { get ; set ; }
18+
19+ /// <summary>
20+ /// The type of the document
21+ /// </summary>
1122 [ JsonProperty ( "_type" ) ]
1223 TypeName Type { get ; set ; }
24+
25+ /// <summary>
26+ /// The id of the document
27+ /// </summary>
1328 [ JsonProperty ( "_id" ) ]
1429 Id Id { get ; set ; }
30+
31+ /// <summary>
32+ /// A document not indexed in Elasticsearch,
33+ /// to generate term vectors for
34+ /// </summary>
1535 [ JsonProperty ( "doc" ) ]
1636 [ JsonConverter ( typeof ( SourceConverter ) ) ]
1737 object Document { get ; set ; }
38+
39+ /// <summary>
40+ /// The document field to generate term
41+ /// vectors for
42+ /// </summary>
1843 [ JsonProperty ( "fields" ) ]
44+ // TODO: Rename to Fields in 7.x
1945 Fields StoredFields { get ; set ; }
46+
47+ /// <summary>
48+ /// Whether to include the start and end offsets.
49+ /// Default is <c>true</c>.
50+ /// </summary>
2051 [ JsonProperty ( "offsets" ) ]
2152 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>
2258 [ JsonProperty ( "payloads" ) ]
2359 bool ? Payloads { get ; set ; }
60+
61+ /// <summary>
62+ /// Whether to include the term positions.
63+ /// Default is <c>true</c>
64+ /// </summary>
2465 [ JsonProperty ( "positions" ) ]
2566 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>
2675 [ JsonProperty ( "term_statistics" ) ]
2776 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>
2885 [ JsonProperty ( "field_statistics" ) ]
2986 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>
3093 [ JsonProperty ( "filter" ) ]
3194 ITermVectorFilter Filter { get ; set ; }
95+
96+ /// <summary>
97+ /// The version number
98+ /// </summary>
3299 [ JsonProperty ( "version" ) ]
33100 long ? Version { get ; set ; }
101+
102+ /// <summary>
103+ /// The type of version
104+ /// </summary>
34105 [ JsonProperty ( "version_type" ) ]
35106 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>
36113 [ JsonProperty ( "routing" ) ]
37114 Routing Routing { get ; set ; }
38115 }
39116
117+ /// <inheritdoc />
40118 public class MultiTermVectorOperation < T > : IMultiTermVectorOperation
41119 where T : class
42120 {
121+ private Routing _routing ;
43122
44123 public MultiTermVectorOperation ( Id id )
45124 {
@@ -48,31 +127,46 @@ public MultiTermVectorOperation(Id id)
48127 this . Type = typeof ( T ) ;
49128 }
50129
130+ /// <inheritdoc />
51131 public IndexName Index { get ; set ; }
132+ /// <inheritdoc />
52133 public TypeName Type { get ; set ; }
134+ /// <inheritdoc />
53135 public Id Id { get ; set ; }
136+ /// <inheritdoc />
54137 public object Document { get ; set ; }
138+ /// <inheritdoc />
55139 public Fields StoredFields { get ; set ; }
140+ /// <inheritdoc />
56141 public bool ? Offsets { get ; set ; }
142+ /// <inheritdoc />
57143 public bool ? Payloads { get ; set ; }
144+ /// <inheritdoc />
58145 public bool ? Positions { get ; set ; }
146+ /// <inheritdoc />
59147 public bool ? TermStatistics { get ; set ; }
148+ /// <inheritdoc />
60149 public bool ? FieldStatistics { get ; set ; }
150+ /// <inheritdoc />
61151 public ITermVectorFilter Filter { get ; set ; }
152+ /// <inheritdoc />
62153 public long ? Version { get ; set ; }
154+ /// <inheritdoc />
63155 public VersionType ? VersionType { get ; set ; }
64-
65- private Routing _routing ;
156+ /// <inheritdoc />
66157 public Routing Routing
67158 {
68159 get => _routing ?? ( Document == null ? null : new Routing ( Document ) ) ;
69160 set => _routing = value ;
70161 }
71162 }
72163
164+ /// <inheritdoc cref="IMultiTermVectorOperation"/>
73165 public class MultiTermVectorOperationDescriptor < T > : DescriptorBase < MultiTermVectorOperationDescriptor < T > , IMultiTermVectorOperation > , IMultiTermVectorOperation
74166 where T : class
75167 {
168+ private Routing _routing ;
169+
76170 IndexName IMultiTermVectorOperation . Index { get ; set ; } = typeof ( T ) ;
77171 TypeName IMultiTermVectorOperation . Type { get ; set ; } = typeof ( T ) ;
78172 Id IMultiTermVectorOperation . Id { get ; set ; }
@@ -86,40 +180,59 @@ public class MultiTermVectorOperationDescriptor<T> : DescriptorBase<MultiTermVec
86180 ITermVectorFilter IMultiTermVectorOperation . Filter { get ; set ; }
87181 long ? IMultiTermVectorOperation . Version { get ; set ; }
88182 VersionType ? IMultiTermVectorOperation . VersionType { get ; set ; }
89-
90- private Routing _routing ;
91183 Routing IMultiTermVectorOperation . Routing
92184 {
93185 get => _routing ?? ( Self . Document == null ? null : new Routing ( Self . Document ) ) ;
94186 set => _routing = value ;
95187 }
96188
189+ /// <inheritdoc cref="IMultiTermVectorOperation.StoredFields"/>
190+ // TODO: Rename to Fields in 7.x
97191 public MultiTermVectorOperationDescriptor < T > StoredFields ( Func < FieldsDescriptor < T > , IPromise < Fields > > fields ) =>
98192 Assign ( a => a . StoredFields = fields ? . Invoke ( new FieldsDescriptor < T > ( ) ) ? . Value ) ;
99193
194+ /// <inheritdoc cref="IMultiTermVectorOperation.StoredFields"/>
195+ // TODO: Rename to Fields in 7.x
100196 public MultiTermVectorOperationDescriptor < T > StoredFields ( Fields fields ) => Assign ( a => a . StoredFields = fields ) ;
101197
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 ) ;
103206
207+ /// <inheritdoc cref="IMultiTermVectorOperation.Document"/>
104208 public MultiTermVectorOperationDescriptor < T > Document ( T document ) => Assign ( a => a . Document = document ) ;
105209
210+ /// <inheritdoc cref="IMultiTermVectorOperation.Offsets"/>
106211 public MultiTermVectorOperationDescriptor < T > Offsets ( bool ? offsets = true ) => Assign ( a => a . Offsets = offsets ) ;
107212
213+ /// <inheritdoc cref="IMultiTermVectorOperation.Payloads"/>
108214 public MultiTermVectorOperationDescriptor < T > Payloads ( bool ? payloads = true ) => Assign ( a => a . Payloads = payloads ) ;
109215
216+ /// <inheritdoc cref="IMultiTermVectorOperation.Positions"/>
110217 public MultiTermVectorOperationDescriptor < T > Positions ( bool ? positions = true ) => Assign ( a => a . Positions = positions ) ;
111218
219+ /// <inheritdoc cref="IMultiTermVectorOperation.TermStatistics"/>
112220 public MultiTermVectorOperationDescriptor < T > TermStatistics ( bool ? termStatistics = true ) => Assign ( a => a . TermStatistics = termStatistics ) ;
113221
222+ /// <inheritdoc cref="IMultiTermVectorOperation.FieldStatistics"/>
114223 public MultiTermVectorOperationDescriptor < T > FieldStatistics ( bool ? fieldStatistics = true ) => Assign ( a => a . FieldStatistics = fieldStatistics ) ;
115224
225+ /// <inheritdoc cref="IMultiTermVectorOperation.Filter"/>
116226 public MultiTermVectorOperationDescriptor < T > Filter ( Func < TermVectorFilterDescriptor , ITermVectorFilter > filterSelector ) =>
117227 Assign ( a => a . Filter = filterSelector ? . Invoke ( new TermVectorFilterDescriptor ( ) ) ) ;
118228
229+ /// <inheritdoc cref="IMultiTermVectorOperation.Version"/>
119230 public MultiTermVectorOperationDescriptor < T > Version ( long ? version ) => Assign ( a => a . Version = version ) ;
120231
232+ /// <inheritdoc cref="IMultiTermVectorOperation.VersionType"/>
121233 public MultiTermVectorOperationDescriptor < T > VersionType ( VersionType ? versionType ) => Assign ( a => a . VersionType = versionType ) ;
122234
235+ /// <inheritdoc cref="IMultiTermVectorOperation.Routing"/>
123236 public MultiTermVectorOperationDescriptor < T > Routing ( Routing routing ) => Assign ( a => a . Routing = routing ) ;
124237 }
125238}
0 commit comments