File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Nest.Tests.Unit/Search/SearchOptions Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,16 @@ public void TestExecuteOnPrimary()
9090 StringAssert . Contains ( "preference=_primary" , result . ConnectionStatus . RequestUrl ) ;
9191 }
9292 [ Test ]
93+ public void TestExecuteOnPrimaryFirst ( )
94+ {
95+ var s = new SearchDescriptor < ElasticSearchProject > ( )
96+ . From ( 0 )
97+ . Size ( 10 )
98+ . ExecuteOnPrimaryFirst ( ) ;
99+ var result = this . _client . Search ( s ) ;
100+ StringAssert . Contains ( "preference=_primary_first" , result . ConnectionStatus . RequestUrl ) ;
101+ }
102+ [ Test ]
93103 public void TestExecuteOnLocalShard ( )
94104 {
95105 var s = new SearchDescriptor < ElasticSearchProject > ( )
Original file line number Diff line number Diff line change @@ -373,6 +373,21 @@ public SearchDescriptor<T> ExecuteOnPrimary()
373373 /// By default, the operation is randomized between the each shard replicas.
374374 /// </para>
375375 /// <para>
376+ /// The operation will go and be executed on the primary shard, and if not available (failover),
377+ /// will execute on other shards.
378+ /// </para>
379+ /// </summary>
380+ public SearchDescriptor < T > ExecuteOnPrimaryFirst ( )
381+ {
382+ this . _Preference = "_primary_first" ;
383+ return this ;
384+ }
385+ /// <summary>
386+ /// <para>
387+ /// Controls a preference of which shard replicas to execute the search request on.
388+ /// By default, the operation is randomized between the each shard replicas.
389+ /// </para>
390+ /// <para>
376391 /// The operation will prefer to be executed on a local allocated shard is possible.
377392 /// </para>
378393 /// </summary>
You can’t perform that action at this time.
0 commit comments