@@ -3525,18 +3525,17 @@ public void testConstantKeywordFieldNoHighlightingQueryString() throws IOExcepti
35253525 String index = "test" ;
35263526 String constantKeywordFieldName = "test_constant_keyword_field" ;
35273527 String constantValue = "constant_value" ;
3528- String queryString = "foobar" ;
35293528
35303529 XContentBuilder mappings = prepareConstantKeywordMappings (constantKeywordFieldName , constantValue );
35313530 assertAcked (prepareCreate (index ).setMapping (mappings ));
35323531
35333532 XContentBuilder document = jsonBuilder ().startObject ().field ("foo" , "bar" ).endObject ();
35343533 saveDocumentIntoIndex (index , "1" , document );
35353534
3536- SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .queryStringQuery (queryString ));
3535+ SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .queryStringQuery ("bar" ));
35373536
35383537 assertNoFailures (search );
3539- assertHitCount (search , 0 );
3538+ assertNotHighlighted (search , 0 , constantKeywordFieldName );
35403539 }
35413540
35423541 public void testConstantKeywordFieldHighlightingSimpleQueryString () throws IOException {
@@ -3563,18 +3562,17 @@ public void testConstantKeywordFieldNoHighlightingSimpleQueryString() throws IOE
35633562 String index = "test" ;
35643563 String constantKeywordFieldName = "test_constant_keyword_field" ;
35653564 String constantValue = "constant_value" ;
3566- String queryString = "foobar" ;
35673565
35683566 XContentBuilder mappings = prepareConstantKeywordMappings (constantKeywordFieldName , constantValue );
35693567 assertAcked (prepareCreate (index ).setMapping (mappings ));
35703568
35713569 XContentBuilder document = jsonBuilder ().startObject ().field ("foo" , "bar" ).endObject ();
35723570 saveDocumentIntoIndex (index , "1" , document );
35733571
3574- SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .simpleQueryStringQuery (queryString ));
3572+ SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .simpleQueryStringQuery ("bar" ));
35753573
35763574 assertNoFailures (search );
3577- assertHitCount (search , 0 );
3575+ assertNotHighlighted (search , 0 , constantKeywordFieldName );
35783576 }
35793577
35803578 public void testConstantKeywordFieldHighlightingTerm () throws IOException {
@@ -3601,7 +3599,6 @@ public void testConstantKeywordFieldNoHighlightingTerm() throws IOException {
36013599 String index = "test" ;
36023600 String constantKeywordFieldName = "test_constant_keyword_field" ;
36033601 String constantValue = "constant_value" ;
3604- String termValue = "foobar" ;
36053602
36063603 XContentBuilder mappings = prepareConstantKeywordMappings (constantKeywordFieldName , constantValue );
36073604 assertAcked (prepareCreate (index ).setMapping (mappings ));
@@ -3612,10 +3609,10 @@ public void testConstantKeywordFieldNoHighlightingTerm() throws IOException {
36123609 .endObject ();
36133610 saveDocumentIntoIndex (index , "1" , document );
36143611
3615- SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .termQuery (constantKeywordFieldName , termValue ));
3612+ SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .termQuery ("foo" , "bar" ));
36163613
36173614 assertNoFailures (search );
3618- assertHitCount (search , 0 );
3615+ assertNotHighlighted (search , 0 , constantKeywordFieldName );
36193616 }
36203617
36213618 public void testConstantKeywordFieldHighlightingWildcard () throws IOException {
@@ -3651,17 +3648,15 @@ public void testConstantKeywordFieldNoHighlightingWildcard() throws IOException
36513648 assertAcked (prepareCreate (index ).setMapping (mappings ));
36523649
36533650 XContentBuilder document = jsonBuilder ().startObject ()
3654- .field ("foo" , "bar " )
3651+ .field ("foo" , "foobar " )
36553652 .field (constantKeywordFieldName , constantValue )
36563653 .endObject ();
36573654 saveDocumentIntoIndex (index , "1" , document );
36583655
3659- SearchResponse search = prepareConstantKeywordSearch (
3660- QueryBuilders .wildcardQuery (constantKeywordFieldName , partialConstantValueWithWildCard )
3661- );
3656+ SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .wildcardQuery ("foo" , "foob*" ));
36623657
36633658 assertNoFailures (search );
3664- assertHitCount (search , 0 );
3659+ assertNotHighlighted (search , 0 , constantKeywordFieldName );
36653660 }
36663661
36673662 public void testConstantKeywordFieldHighlightingPrefix () throws IOException {
@@ -3695,15 +3690,15 @@ public void testConstantKeywordFieldNoHighlightingPrefix() throws IOException {
36953690 assertAcked (prepareCreate (index ).setMapping (mappings ));
36963691
36973692 XContentBuilder document = jsonBuilder ().startObject ()
3698- .field ("foo" , "bar " )
3693+ .field ("foo" , "foobar " )
36993694 .field (constantKeywordFieldName , constantValue )
37003695 .endObject ();
37013696 saveDocumentIntoIndex (index , "1" , document );
37023697
3703- SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .prefixQuery (constantKeywordFieldName , prefixConstantValue ));
3698+ SearchResponse search = prepareConstantKeywordSearch (QueryBuilders .prefixQuery ("foo" , "foob" ));
37043699
37053700 assertNoFailures (search );
3706- assertHitCount (search , 0 );
3701+ assertNotHighlighted (search , 0 , constantKeywordFieldName );
37073702 }
37083703
37093704 public void testImplicitConstantKeywordFieldHighlighting () throws IOException {
0 commit comments