@@ -53,12 +53,14 @@ public interface ISearchTemplateRequest
5353
5454 Type ClrType { get ; }
5555
56- [ JsonProperty ( PropertyName = "sort" ) ]
57- [ JsonConverter ( typeof ( SortCollectionConverter ) ) ]
58- IList < KeyValuePair < PropertyPathMarker , ISort > > Sort { get ; set ; }
59-
6056 [ JsonProperty ( PropertyName = "template" ) ]
61- SearchTemplate Template { get ; set ; }
57+ string Template { get ; set ; }
58+
59+ [ JsonProperty ( "file" ) ]
60+ string File { get ; set ; }
61+
62+ [ JsonProperty ( "id" ) ]
63+ string Id { get ; set ; }
6264
6365 Func < dynamic , Hit < dynamic > , Type > TypeSelector { get ; set ; }
6466 }
@@ -68,11 +70,12 @@ public interface ISearchTemplateRequest<T> : ISearchTemplateRequest { }
6870 public partial class SearchTemplateRequest
6971 : QueryPathBase < SearchTemplateRequestParameters > , ISearchTemplateRequest
7072 {
71- public SearchTemplate Template { get ; set ; }
73+ public string Template { get ; set ; }
74+ public string File { get ; set ; }
75+ public string Id { get ; set ; }
7276 public IDictionary < string , object > Params { get ; set ; }
7377 private Type _clrType { get ; set ; }
7478 Type ISearchTemplateRequest . ClrType { get { return _clrType ; } }
75- public IList < KeyValuePair < PropertyPathMarker , ISort > > Sort { get ; set ; }
7679 public Func < dynamic , Hit < dynamic > , Type > TypeSelector { get ; set ; }
7780
7881 protected override void UpdatePathInfo ( IConnectionSettingsValues settings , ElasticsearchPathInfo < SearchTemplateRequestParameters > pathInfo )
@@ -85,10 +88,11 @@ public partial class SearchTemplateRequest<T>
8588 : QueryPathBase < SearchTemplateRequestParameters , T > , ISearchTemplateRequest
8689 where T : class
8790 {
88- public SearchTemplate Template { get ; set ; }
91+ public string Template { get ; set ; }
92+ public string File { get ; set ; }
93+ public string Id { get ; set ; }
8994 public IDictionary < string , object > Params { get ; set ; }
9095 public Type ClrType { get { return typeof ( T ) ; } }
91- public IList < KeyValuePair < PropertyPathMarker , ISort > > Sort { get ; set ; }
9296 public Func < dynamic , Hit < dynamic > , Type > TypeSelector { get ; set ; }
9397
9498 protected override void UpdatePathInfo ( IConnectionSettingsValues settings , ElasticsearchPathInfo < SearchTemplateRequestParameters > pathInfo )
@@ -110,19 +114,31 @@ public partial class SearchTemplateDescriptor<T>
110114 /// </summary>
111115 internal bool _Strict { get ; set ; }
112116
113- SearchTemplate ISearchTemplateRequest . Template { get ; set ; }
117+ string ISearchTemplateRequest . Template { get ; set ; }
114118
115- IDictionary < string , object > ISearchTemplateRequest . Params { get ; set ; }
119+ string ISearchTemplateRequest . File { get ; set ; }
116120
117- IList < KeyValuePair < PropertyPathMarker , ISort > > ISearchTemplateRequest . Sort { get ; set ; }
121+ string ISearchTemplateRequest . Id { get ; set ; }
122+
123+ IDictionary < string , object > ISearchTemplateRequest . Params { get ; set ; }
118124
119125 Func < dynamic , Hit < dynamic > , Type > ISearchTemplateRequest . TypeSelector { get ; set ; }
120126
121- public SearchTemplateDescriptor < T > Template ( Func < TemplateDescriptor , TemplateDescriptor > templateSelector )
127+ public SearchTemplateDescriptor < T > Template ( string template )
128+ {
129+ this . Self . Template = template ;
130+ return this ;
131+ }
132+
133+ public SearchTemplateDescriptor < T > File ( string file )
134+ {
135+ this . Self . File = file ;
136+ return this ;
137+ }
138+
139+ public SearchTemplateDescriptor < T > Id ( string id )
122140 {
123- templateSelector . ThrowIfNull ( "templateSelector" ) ;
124- var descriptor = templateSelector ( new TemplateDescriptor ( ) ) ;
125- this . Self . Template = descriptor . Template ;
141+ this . Self . Id = id ;
126142 return this ;
127143 }
128144
@@ -140,21 +156,6 @@ public SearchTemplateDescriptor<T> Params(Func<FluentDictionary<string, object>,
140156 return this ;
141157 }
142158
143- /// <summary>
144- /// <para>Sort() allows you to fully describe your sort unlike the SortAscending and SortDescending aliases.
145- /// </para>
146- /// </summary>
147- public SearchTemplateDescriptor < T > Sort ( Func < SortFieldDescriptor < T > , IFieldSort > sortSelector )
148- {
149- if ( Self . Sort == null )
150- Self . Sort = new List < KeyValuePair < PropertyPathMarker , ISort > > ( ) ;
151-
152- sortSelector . ThrowIfNull ( "sortSelector" ) ;
153- var descriptor = sortSelector ( new SortFieldDescriptor < T > ( ) ) ;
154- Self . Sort . Add ( new KeyValuePair < PropertyPathMarker , ISort > ( descriptor . Field , descriptor ) ) ;
155- return this ;
156- }
157-
158159 public SearchTemplateDescriptor < T > ConcreteTypeSelector ( Func < dynamic , Hit < dynamic > , Type > typeSelector )
159160 {
160161 Self . TypeSelector = typeSelector ;
@@ -166,43 +167,4 @@ protected override void UpdatePathInfo(IConnectionSettingsValues settings, Elast
166167 SearchTemplatePathInfo . Update ( pathInfo ) ;
167168 }
168169 }
169-
170- [ JsonObject ]
171- public class SearchTemplate
172- {
173- [ JsonProperty ( "file" ) ]
174- public string File { get ; set ; }
175-
176- [ JsonProperty ( "id" ) ]
177- public string Id { get ; set ; }
178-
179- [ JsonProperty ( "query" ) ]
180- public IQueryContainer Query { get ; set ; }
181- }
182-
183- public class TemplateDescriptor
184- {
185- public SearchTemplate Template = new SearchTemplate ( ) ;
186-
187- public TemplateDescriptor File ( string file )
188- {
189- Template . File = file ;
190- return this ;
191- }
192-
193- public TemplateDescriptor Id ( string id )
194- {
195- Template . Id = id ;
196- return this ;
197- }
198-
199- public TemplateDescriptor Query < T > ( Func < QueryDescriptor < T > , QueryContainer > query ) where T : class
200- {
201- query . ThrowIfNull ( "query" ) ;
202- var q = new QueryDescriptor < T > ( ) ;
203- ( ( IQueryContainer ) q ) . IsStrict = true ;
204- Template . Query = query ( q ) ;
205- return this ;
206- }
207- }
208170}
0 commit comments