@@ -540,7 +540,7 @@ public void testReduceFromSeveralShards() throws IOException, ExecutionException
540540 * Ensure requests using nondeterministic scripts do not get cached.
541541 */
542542 public void testScriptCaching () throws Exception {
543- assertAcked (prepareCreate ("cache_test_idx" ).setMapping ("d" , "type=long" , "s" , "type=text" )
543+ assertAcked (prepareCreate ("cache_test_idx" ).setMapping ("d" , "type=long" )
544544 .setSettings (Settings .builder ().put ("requests.cache.enable" , true ).put ("number_of_shards" , 1 ).put ("number_of_replicas" , 1 ))
545545 .get ());
546546 indexRandom (true , client ().prepareIndex ("cache_test_idx" ).setId ("1" ).setSource ("s" , 1 ),
@@ -556,15 +556,9 @@ public void testScriptCaching() throws Exception {
556556 ScriptHeuristic scriptHeuristic = new ScriptHeuristic (
557557 new Script (ScriptType .INLINE , "mockscript" , "Math.random()" , Collections .emptyMap ())
558558 );
559- boolean useSigText = randomBoolean ();
560559 SearchResponse r ;
561- if (useSigText ) {
562- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
563- .addAggregation (significantText ("foo" , "s" ).significanceHeuristic (scriptHeuristic )).get ();
564- } else {
565- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
566- .addAggregation (significantTerms ("foo" ).field ("s" ).significanceHeuristic (scriptHeuristic )).get ();
567- }
560+ r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
561+ .addAggregation (significantTerms ("foo" ).field ("s" ).significanceHeuristic (scriptHeuristic )).get ();
568562 assertSearchResponse (r );
569563
570564 assertThat (client ().admin ().indices ().prepareStats ("cache_test_idx" ).setRequestCache (true ).get ().getTotal ().getRequestCache ()
@@ -574,14 +568,8 @@ public void testScriptCaching() throws Exception {
574568
575569 // Test that a request using a deterministic script gets cached
576570 scriptHeuristic = getScriptSignificanceHeuristic ();
577- useSigText = randomBoolean ();
578- if (useSigText ) {
579- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
580- .addAggregation (significantText ("foo" , "s" ).significanceHeuristic (scriptHeuristic )).get ();
581- } else {
582- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
583- .addAggregation (significantTerms ("foo" ).field ("s" ).significanceHeuristic (scriptHeuristic )).get ();
584- }
571+ r = client ().prepareSearch ("cache_test_idx" ).setSize (0 )
572+ .addAggregation (significantTerms ("foo" ).field ("s" ).significanceHeuristic (scriptHeuristic )).get ();
585573 assertSearchResponse (r );
586574
587575 assertThat (client ().admin ().indices ().prepareStats ("cache_test_idx" ).setRequestCache (true ).get ().getTotal ().getRequestCache ()
@@ -590,11 +578,7 @@ public void testScriptCaching() throws Exception {
590578 .getMissCount (), equalTo (1L ));
591579
592580 // Ensure that non-scripted requests are cached as normal
593- if (useSigText ) {
594- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 ).addAggregation (significantText ("foo" , "s" )).get ();
595- } else {
596- r = client ().prepareSearch ("cache_test_idx" ).setSize (0 ).addAggregation (significantTerms ("foo" ).field ("s" )).get ();
597- }
581+ r = client ().prepareSearch ("cache_test_idx" ).setSize (0 ).addAggregation (significantTerms ("foo" ).field ("s" )).get ();
598582 assertSearchResponse (r );
599583
600584 assertThat (client ().admin ().indices ().prepareStats ("cache_test_idx" ).setRequestCache (true ).get ().getTotal ().getRequestCache ()
0 commit comments