@@ -28,7 +28,7 @@ public abstract class SearchDescriptorBase
2828
2929 internal Func < dynamic , Hit < dynamic > , Type > _ConcreteTypeSelector ;
3030
31-
31+
3232 }
3333
3434 [ JsonObject ( MemberSerialization = MemberSerialization . OptIn ) ]
@@ -412,6 +412,39 @@ public SearchDescriptor<T> ExecuteOnNode(string node)
412412 return this ;
413413 }
414414 /// <summary>
415+ /// <para>
416+ /// Controls a preference of which shard replicas to execute the search request on.
417+ /// By default, the operation is randomized between the each shard replicas.
418+ /// </para>
419+ /// <para>
420+ /// A custom value will be used to guarantee that the same shards will be used for
421+ /// the same custom value. This can help with "jumping values" when hitting different
422+ /// shards in different refresh states. A sample value can be something like the
423+ /// web session id, or the user name.
424+ /// </para>
425+ /// </summary>
426+ public SearchDescriptor < T > ExecuteOnCustomNode ( string node )
427+ {
428+ node . ThrowIfNull ( "node" ) ;
429+ this . _Preference = node ;
430+ return this ;
431+ }
432+ /// <summary>
433+ /// <para>
434+ /// Controls a preference of which shard replicas to execute the search request on.
435+ /// By default, the operation is randomized between the each shard replicas.
436+ /// </para>
437+ /// <para>
438+ /// Prefers execution on the node with the provided node id if applicable.
439+ /// </para>
440+ /// </summary>
441+ public SearchDescriptor < T > ExecuteOnPreferredNode ( string node )
442+ {
443+ node . ThrowIfNull ( "node" ) ;
444+ this . _Preference = string . Format ( "_prefer_node:{0}" , node ) ;
445+ return this ;
446+ }
447+ /// <summary>
415448 /// Allows to configure different boost level per index when searching across
416449 /// more than one indices. This is very handy when hits coming from one index
417450 /// matter more than hits coming from another index (think social graph where each user has an index).
@@ -888,26 +921,26 @@ public SearchDescriptor<T> PhraseSuggest(string name, Func<PhraseSuggestDescript
888921 return this ;
889922 }
890923
891- public SearchDescriptor < T > CompletionSuggest ( string name , Func < CompletionSuggestDescriptor < T > , CompletionSuggestDescriptor < T > > suggest )
892- {
893- name . ThrowIfNullOrEmpty ( "name" ) ;
894- suggest . ThrowIfNull ( "suggest" ) ;
895- if ( this . _Suggest == null )
896- this . _Suggest = new Dictionary < String , SuggestDescriptorBucket < T > > ( ) ;
897- CompletionSuggestDescriptor < T > desc = new CompletionSuggestDescriptor < T > ( ) ;
898- CompletionSuggestDescriptor < T > item = suggest ( desc ) ;
899- SuggestDescriptorBucket < T > bucket = new SuggestDescriptorBucket < T > { _Text = item . _Text , CompletionSuggest = item } ;
900- this . _Suggest . Add ( name , bucket ) ;
901- return this ;
902- }
924+ public SearchDescriptor < T > CompletionSuggest ( string name , Func < CompletionSuggestDescriptor < T > , CompletionSuggestDescriptor < T > > suggest )
925+ {
926+ name . ThrowIfNullOrEmpty ( "name" ) ;
927+ suggest . ThrowIfNull ( "suggest" ) ;
928+ if ( this . _Suggest == null )
929+ this . _Suggest = new Dictionary < String , SuggestDescriptorBucket < T > > ( ) ;
930+ CompletionSuggestDescriptor < T > desc = new CompletionSuggestDescriptor < T > ( ) ;
931+ CompletionSuggestDescriptor < T > item = suggest ( desc ) ;
932+ SuggestDescriptorBucket < T > bucket = new SuggestDescriptorBucket < T > { _Text = item . _Text , CompletionSuggest = item } ;
933+ this . _Suggest . Add ( name , bucket ) ;
934+ return this ;
935+ }
903936
904937 /// <summary>
905938 /// Describe the query to perform using a query descriptor lambda
906939 /// </summary>
907940 public SearchDescriptor < T > Query ( Func < QueryDescriptor < T > , BaseQuery > query )
908941 {
909942 query . ThrowIfNull ( "query" ) ;
910- var q = new QueryDescriptor < T > ( ) { IsStrict = this . _Strict } ;
943+ var q = new QueryDescriptor < T > ( ) { IsStrict = this . _Strict } ;
911944
912945 var bq = query ( q ) ;
913946 return this . Query ( bq ) ;
0 commit comments