11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4+ using System . Linq . Expressions ;
45using System . Text ;
56using Elasticsearch . Net ;
7+ using Nest . Resolvers ;
8+ using Newtonsoft . Json ;
69
710namespace Nest
811{
912 [ DescriptorFor ( "Mtermvectors" ) ]
1013 public partial class MultiTermVectorsDescriptor < T > : IndexTypePathTypedDescriptor < MultiTermVectorsDescriptor < T > , MultiTermVectorsRequestParameters , T >
1114 , IPathInfo < MultiTermVectorsRequestParameters > where T : class
1215 {
16+ [ JsonProperty ( "docs" ) ]
17+ internal IEnumerable < MultiTermVectorDocument > _Documents { get ; set ; }
18+
19+ public MultiTermVectorsDescriptor < T > Documents ( params Func < MultiTermVectorDocumentDescriptor < T > , IMultiTermVectorDocumentDescriptor > [ ] documentSelectors )
20+ {
21+ this . _Documents = documentSelectors . Select ( s => s ( new MultiTermVectorDocumentDescriptor < T > ( ) ) . GetDocument ( ) ) . Where ( d=> d != null ) . ToList ( ) ;
22+ return this ;
23+ }
24+
1325 ElasticsearchPathInfo < MultiTermVectorsRequestParameters > IPathInfo < MultiTermVectorsRequestParameters > . ToPathInfo ( IConnectionSettingsValues settings )
1426 {
1527 var pathInfo = base . ToPathInfo ( settings , this . _QueryString ) ;
@@ -18,4 +30,90 @@ ElasticsearchPathInfo<MultiTermVectorsRequestParameters> IPathInfo<MultiTermVect
1830 return pathInfo ;
1931 }
2032 }
33+
34+ public interface IMultiTermVectorDocumentDescriptor
35+ {
36+ MultiTermVectorDocument Document { get ; set ; }
37+ MultiTermVectorDocument GetDocument ( ) ;
38+ }
39+
40+ public class MultiTermVectorDocumentDescriptor < T > : DocumentOptionalPathDescriptorBase < MultiTermVectorDocumentDescriptor < T > , T , MultiTermVectorsRequestParameters > , IMultiTermVectorDocumentDescriptor where T : class
41+ {
42+
43+ MultiTermVectorDocument IMultiTermVectorDocumentDescriptor . Document { get ; set ; }
44+ MultiTermVectorDocument IMultiTermVectorDocumentDescriptor . GetDocument ( )
45+ {
46+ IMultiTermVectorDocumentDescriptor d = this ;
47+ if ( d . Document == null ) d . Document = new MultiTermVectorDocument ( ) ;
48+ d . Document . Id = this . _Id ;
49+ d . Document . Type = this . _Type ;
50+ d . Document . Index = this . _Index ;
51+ return d . Document ;
52+ }
53+
54+ private MultiTermVectorDocumentDescriptor < T > SetDocValue ( Action < IMultiTermVectorDocumentDescriptor > setter )
55+ {
56+ IMultiTermVectorDocumentDescriptor d = this ;
57+ if ( d . Document == null ) d . Document = new MultiTermVectorDocument ( ) ;
58+ setter ( d ) ;
59+ return this ;
60+ }
61+
62+ public MultiTermVectorDocumentDescriptor < T > Fields ( params string [ ] fields )
63+ {
64+ return this . SetDocValue ( d => d . Document . Fields = fields . Select ( f => ( PropertyPathMarker ) f ) . ToList ( ) ) ;
65+ }
66+ public MultiTermVectorDocumentDescriptor < T > Fields ( params Expression < Func < T , object > > [ ] fields )
67+ {
68+ return this . SetDocValue ( d => d . Document . Fields = fields . Select ( f => ( PropertyPathMarker ) f ) . ToList ( ) ) ;
69+ }
70+ public MultiTermVectorDocumentDescriptor < T > Fields ( Func < FluentFieldList < T > , FluentFieldList < T > > fields )
71+ {
72+ return this . SetDocValue ( d => d . Document . Fields = fields ( new FluentFieldList < T > ( ) ) . ToList ( ) ) ;
73+ }
74+
75+
76+ public MultiTermVectorDocumentDescriptor < T > Offsets ( bool offsets = true )
77+ {
78+ return this . SetDocValue ( d => d . Document . Offsets = offsets ) ;
79+ }
80+ public MultiTermVectorDocumentDescriptor < T > Payloads ( bool payloads = true )
81+ {
82+ return this . SetDocValue ( d => d . Document . Payloads = payloads ) ;
83+ }
84+ public MultiTermVectorDocumentDescriptor < T > Positions ( bool positions = true )
85+ {
86+ return this . SetDocValue ( d => d . Document . Positions = positions ) ;
87+ }
88+ public MultiTermVectorDocumentDescriptor < T > TermStatistics ( bool termStatistics = true )
89+ {
90+ return this . SetDocValue ( d => d . Document . TermStatistics = termStatistics ) ;
91+ }
92+ public MultiTermVectorDocumentDescriptor < T > FieldStatistics ( bool fieldStatistics = true )
93+ {
94+ return this . SetDocValue ( d => d . Document . FieldStatistics = fieldStatistics ) ;
95+ }
96+ }
97+
98+ public class MultiTermVectorDocument
99+ {
100+ [ JsonProperty ( "_index" ) ]
101+ public IndexNameMarker Index { get ; set ; }
102+ [ JsonProperty ( "_type" ) ]
103+ public TypeNameMarker Type { get ; set ; }
104+ [ JsonProperty ( "_id" ) ]
105+ public string Id { get ; set ; }
106+ [ JsonProperty ( "fields" ) ]
107+ public IEnumerable < PropertyPathMarker > Fields { get ; set ; }
108+ [ JsonProperty ( "offsets" ) ]
109+ public bool ? Offsets { get ; set ; }
110+ [ JsonProperty ( "payloads" ) ]
111+ public bool ? Payloads { get ; set ; }
112+ [ JsonProperty ( "positions" ) ]
113+ public bool ? Positions { get ; set ; }
114+ [ JsonProperty ( "term_statistics" ) ]
115+ public bool ? TermStatistics { get ; set ; }
116+ [ JsonProperty ( "field_statistics" ) ]
117+ public bool ? FieldStatistics { get ; set ; }
118+ }
21119}
0 commit comments