55
66namespace Nest
77{
8- public interface IGlobalInnerHit
8+ public interface IGlobalInnerHit : IInnerHits
99 {
1010 [ JsonProperty ( PropertyName = "query" ) ]
1111 IQueryContainer Query { get ; set ; }
@@ -15,7 +15,7 @@ public interface IGlobalInnerHit
1515 IDictionary < string , IInnerHitsContainer > InnerHits { get ; set ; }
1616 }
1717
18- public class GlobalInnerHit : IGlobalInnerHit
18+ public class GlobalInnerHit : InnerHits , IGlobalInnerHit
1919 {
2020 public IQueryContainer Query { get ; set ; }
2121 public IDictionary < string , IInnerHitsContainer > InnerHits { get ; set ; }
@@ -27,6 +27,16 @@ public class GlobalInnerHitDescriptor<T> : IGlobalInnerHit where T : class
2727
2828 IQueryContainer IGlobalInnerHit . Query { get ; set ; }
2929 IDictionary < string , IInnerHitsContainer > IGlobalInnerHit . InnerHits { get ; set ; }
30+ string IInnerHits . Name { get ; set ; }
31+ int ? IInnerHits . From { get ; set ; }
32+ int ? IInnerHits . Size { get ; set ; }
33+ IList < KeyValuePair < PropertyPathMarker , ISort > > IInnerHits . Sort { get ; set ; }
34+ IHighlightRequest IInnerHits . Highlight { get ; set ; }
35+ bool ? IInnerHits . Explain { get ; set ; }
36+ ISourceFilter IInnerHits . Source { get ; set ; }
37+ bool ? IInnerHits . Version { get ; set ; }
38+ IEnumerable < string > IInnerHits . FielddataFields { get ; set ; }
39+ IDictionary < string , IScriptFilter > IInnerHits . ScriptFields { get ; set ; }
3040
3141 public GlobalInnerHitDescriptor < T > Query ( Func < QueryDescriptor < T > , IQueryContainer > querySelector )
3242 {
@@ -58,5 +68,112 @@ public GlobalInnerHitDescriptor<T> InnerHits(
5868 Self . InnerHits = containers ;
5969 return this ;
6070 }
71+
72+ public GlobalInnerHitDescriptor < T > From ( int ? from )
73+ {
74+ Self . From = from ;
75+ return this ;
76+ }
77+
78+ public GlobalInnerHitDescriptor < T > Size ( int ? size )
79+ {
80+ Self . Size = size ;
81+ return this ;
82+ }
83+
84+ public GlobalInnerHitDescriptor < T > Name ( string name )
85+ {
86+ Self . Name = name ;
87+ return this ;
88+ }
89+
90+ public GlobalInnerHitDescriptor < T > FielddataFields ( params string [ ] fielddataFields )
91+ {
92+ Self . FielddataFields = fielddataFields ;
93+ return this ;
94+ }
95+
96+ public GlobalInnerHitDescriptor < T > FielddataFields ( IEnumerable < string > fielddataFields )
97+ {
98+ Self . FielddataFields = fielddataFields ;
99+ return this ;
100+ }
101+
102+ public GlobalInnerHitDescriptor < T > Explain ( bool explain = true )
103+ {
104+ Self . Explain = explain ;
105+ return this ;
106+ }
107+
108+ public GlobalInnerHitDescriptor < T > Version ( bool version = true )
109+ {
110+ Self . Version = version ;
111+ return this ;
112+ }
113+
114+ public GlobalInnerHitDescriptor < T > Sort ( Func < SortDescriptor < T > , SortDescriptor < T > > sortSelector )
115+ {
116+ if ( sortSelector == null ) return this ;
117+
118+ var descriptor = sortSelector ( new SortDescriptor < T > ( ) ) ;
119+
120+ Self . Sort = descriptor . InternalSortState . Count == 0 ? null : descriptor . InternalSortState ;
121+ return this ;
122+ }
123+
124+ /// <summary>
125+ /// Allow to highlight search results on one or more fields. The implementation uses the either lucene fast-vector-highlighter or highlighter.
126+ /// </summary>
127+ public GlobalInnerHitDescriptor < T > Highlight ( Action < HighlightDescriptor < T > > highlightDescriptor )
128+ {
129+ highlightDescriptor . ThrowIfNull ( "highlightDescriptor" ) ;
130+ var d = new HighlightDescriptor < T > ( ) ;
131+ highlightDescriptor ( d ) ;
132+ Self . Highlight = d ;
133+ return this ;
134+ }
135+
136+ public GlobalInnerHitDescriptor < T > Source ( bool include = true )
137+ {
138+ if ( ! include )
139+ {
140+ Self . Source = new SourceFilter
141+ {
142+ Exclude = new PropertyPathMarker [ ] { "*" }
143+ } ;
144+ }
145+ else Self . Source = null ;
146+ return this ;
147+ }
148+
149+ public GlobalInnerHitDescriptor < T > Source ( Func < SearchSourceDescriptor < T > , SearchSourceDescriptor < T > > sourceSelector )
150+ {
151+ if ( sourceSelector == null ) return this ;
152+ Self . Source = sourceSelector ( new SearchSourceDescriptor < T > ( ) ) ;
153+ return this ;
154+ }
155+
156+ public GlobalInnerHitDescriptor < T > ScriptFields (
157+ Func < FluentDictionary < string , Func < ScriptFilterDescriptor , ScriptFilterDescriptor > > ,
158+ FluentDictionary < string , Func < ScriptFilterDescriptor , ScriptFilterDescriptor > > > scriptFields )
159+ {
160+ if ( scriptFields == null ) return null ;
161+
162+ var scriptFieldDescriptors = scriptFields ( new FluentDictionary < string , Func < ScriptFilterDescriptor , ScriptFilterDescriptor > > ( ) ) ;
163+ if ( scriptFieldDescriptors == null || scriptFieldDescriptors . All ( d => d . Value == null ) )
164+ {
165+ Self . ScriptFields = null ;
166+ return this ;
167+ }
168+ Self . ScriptFields = new FluentDictionary < string , IScriptFilter > ( ) ;
169+ foreach ( var d in scriptFieldDescriptors )
170+ {
171+ if ( d . Value == null )
172+ continue ;
173+ Self . ScriptFields . Add ( d . Key , d . Value ( new ScriptFilterDescriptor ( ) ) ) ;
174+ }
175+ return this ;
176+ }
177+
61178 }
62179}
0 commit comments