2020
2121import com .carrotsearch .randomizedtesting .generators .RandomStrings ;
2222import com .google .common .collect .Lists ;
23+ import org .elasticsearch .AbstractSharedClusterTest ;
2324import org .elasticsearch .action .admin .cluster .health .ClusterHealthStatus ;
2425import org .elasticsearch .action .admin .indices .mapping .put .PutMappingResponse ;
2526import org .elasticsearch .action .admin .indices .optimize .OptimizeResponse ;
3940import org .elasticsearch .search .suggest .completion .CompletionSuggestionBuilder ;
4041import org .elasticsearch .search .suggest .completion .CompletionSuggestionFuzzyBuilder ;
4142import org .elasticsearch .test .hamcrest .ElasticsearchAssertions ;
42- import org .elasticsearch .AbstractSharedClusterTest ;
4343import org .junit .Test ;
4444
4545import java .io .IOException ;
@@ -370,6 +370,7 @@ public void testThatUpgradeToMultiFieldWorks() throws Exception {
370370 .startObject (TYPE ).startObject ("properties" )
371371 .startObject (FIELD )
372372 .field ("type" , "multi_field" )
373+ .field ("path" , "just_name" )
373374 .startObject ("fields" )
374375 .startObject (FIELD ).field ("type" , "string" ).endObject ()
375376 .startObject ("suggest" ).field ("type" , "completion" ).field ("index_analyzer" , "simple" ).field ("search_analyzer" , "simple" ).endObject ()
@@ -381,15 +382,15 @@ public void testThatUpgradeToMultiFieldWorks() throws Exception {
381382 assertThat (putMappingResponse .isAcknowledged (), is (true ));
382383
383384 SuggestResponse suggestResponse = client ().prepareSuggest (INDEX ).addSuggestion (
384- new CompletionSuggestionBuilder ("suggs" ).field (FIELD + ". suggest" ).text ("f" ).size (10 )
385+ new CompletionSuggestionBuilder ("suggs" ).field (" suggest" ).text ("f" ).size (10 )
385386 ).execute ().actionGet ();
386387 assertSuggestions (suggestResponse , "suggs" );
387388
388389 client ().prepareIndex (INDEX , TYPE , "1" ).setRefresh (true ).setSource (jsonBuilder ().startObject ().field (FIELD , "Foo Fighters" ).endObject ()).get ();
389390 waitForRelocation (ClusterHealthStatus .GREEN );
390391
391392 SuggestResponse afterReindexingResponse = client ().prepareSuggest (INDEX ).addSuggestion (
392- new CompletionSuggestionBuilder ("suggs" ).field (FIELD + ". suggest" ).text ("f" ).size (10 )
393+ new CompletionSuggestionBuilder ("suggs" ).field (" suggest" ).text ("f" ).size (10 )
393394 ).execute ().actionGet ();
394395 assertSuggestions (afterReindexingResponse , "suggs" , "Foo Fighters" );
395396 }
@@ -684,7 +685,7 @@ private void createData(boolean optimize) throws IOException, InterruptedExcepti
684685 client ().admin ().indices ().prepareOptimize (INDEX ).execute ().actionGet ();
685686 }
686687 }
687-
688+
688689 @ Test // see #3555
689690 public void testPrunedSegments () throws IOException {
690691 createIndexAndMappingAndSettings (settingsBuilder ().put (SETTING_NUMBER_OF_SHARDS , 1 ).put (SETTING_NUMBER_OF_REPLICAS , 0 ), "standard" , "standard" , false , false , false );
@@ -696,43 +697,43 @@ public void testPrunedSegments() throws IOException {
696697 ).get ();
697698 client ().prepareIndex (INDEX , TYPE , "2" ).setSource (jsonBuilder ()
698699 .startObject ()
699- .field ("somefield" , "somevalue" )
700+ .field ("somefield" , "somevalue" )
700701 .endObject ()
701702 ).get (); // we have 2 docs in a segment...
702703 OptimizeResponse actionGet = client ().admin ().indices ().prepareOptimize ().setFlush (true ).setMaxNumSegments (1 ).setRefresh (true ).execute ().actionGet ();
703704 assertNoFailures (actionGet );
704705 // update the first one and then merge.. the target segment will have no value in FIELD
705706 client ().prepareIndex (INDEX , TYPE , "1" ).setSource (jsonBuilder ()
706707 .startObject ()
707- .field ("somefield" , "somevalue" )
708+ .field ("somefield" , "somevalue" )
708709 .endObject ()
709710 ).get ();
710711 actionGet = client ().admin ().indices ().prepareOptimize ().setFlush (true ).setMaxNumSegments (1 ).setRefresh (true ).execute ().actionGet ();
711712 assertNoFailures (actionGet );
712713
713714 assertSuggestions ("b" );
714715 assertThat (2l , equalTo (client ().prepareCount (INDEX ).get ().getCount ()));
715- for (IndexShardSegments seg : client ().admin ().indices ().prepareSegments ().get ().getIndices ().get (INDEX )) {
716+ for (IndexShardSegments seg : client ().admin ().indices ().prepareSegments ().get ().getIndices ().get (INDEX )) {
716717 ShardSegments [] shards = seg .getShards ();
717718 for (ShardSegments shardSegments : shards ) {
718719 assertThat (1 , equalTo (shardSegments .getSegments ().size ()));
719720 }
720721 }
721722 }
722-
723+
723724 @ Test
724725 public void testMaxFieldLength () throws IOException {
725726 client ().admin ().indices ().prepareCreate (INDEX ).get ();
726727 int iters = atLeast (10 );
727728 for (int i = 0 ; i < iters ; i ++) {
728729 int len = between (3 , 50 );
729- String str = replaceReservedChars (randomRealisticUnicodeOfCodepointLengthBetween (len + 1 , atLeast (len + 2 )), (char )0x01 );
730+ String str = replaceReservedChars (randomRealisticUnicodeOfCodepointLengthBetween (len + 1 , atLeast (len + 2 )), (char ) 0x01 );
730731 ElasticsearchAssertions .assertAcked (client ().admin ().indices ().preparePutMapping (INDEX ).setType (TYPE ).setSource (jsonBuilder ().startObject ()
731732 .startObject (TYPE ).startObject ("properties" )
732733 .startObject (FIELD )
733734 .field ("type" , "completion" )
734735 .field ("max_input_len" , len )
735- // upgrade mapping each time
736+ // upgrade mapping each time
736737 .field ("analyzer" , "keyword" )
737738 .endObject ()
738739 .endObject ().endObject ()
@@ -748,14 +749,14 @@ public void testMaxFieldLength() throws IOException {
748749 assertSuggestions (str .substring (0 , prefixLen ), "foobar" );
749750 if (len + 1 < str .length ()) {
750751 assertSuggestions (str .substring (0 , CompletionFieldMapper .correctSubStringLen (str ,
751- len + (Character .isHighSurrogate (str .charAt (len - 1 )) ? 2 : 1 ))));
752+ len + (Character .isHighSurrogate (str .charAt (len - 1 )) ? 2 : 1 ))));
752753 }
753- }
754+ }
754755 }
755-
756+
756757 @ Test
757758 // see #3596
758- public void testVeryLongInput () throws IOException {
759+ public void testVeryLongInput () throws IOException {
759760 client ().admin ().indices ().prepareCreate (INDEX ).get ();
760761 ElasticsearchAssertions .assertAcked (client ().admin ().indices ().preparePutMapping (INDEX ).setType (TYPE ).setSource (jsonBuilder ().startObject ()
761762 .startObject (TYPE ).startObject ("properties" )
@@ -766,19 +767,19 @@ public void testVeryLongInput() throws IOException {
766767 .endObject ()));
767768 ensureYellow ();
768769 // can cause stack overflow without the default max_input_len
769- String longString = replaceReservedChars (randomRealisticUnicodeOfLength (atLeast (5000 )), (char )0x01 );
770+ String longString = replaceReservedChars (randomRealisticUnicodeOfLength (atLeast (5000 )), (char ) 0x01 );
770771 client ().prepareIndex (INDEX , TYPE , "1" ).setSource (jsonBuilder ()
771772 .startObject ().startObject (FIELD )
772773 .startArray ("input" ).value (longString ).endArray ()
773774 .field ("output" , "foobar" )
774775 .endObject ().endObject ()
775776 ).setRefresh (true ).get ();
776-
777+
777778 }
778-
779+
779780 // see #3648
780781 @ Test (expected = MapperParsingException .class )
781- public void testReservedChars () throws IOException {
782+ public void testReservedChars () throws IOException {
782783 client ().admin ().indices ().prepareCreate (INDEX ).get ();
783784 ElasticsearchAssertions .assertAcked (client ().admin ().indices ().preparePutMapping (INDEX ).setType (TYPE ).setSource (jsonBuilder ().startObject ()
784785 .startObject (TYPE ).startObject ("properties" )
@@ -789,16 +790,16 @@ public void testReservedChars() throws IOException {
789790 .endObject ()));
790791 ensureYellow ();
791792 // can cause stack overflow without the default max_input_len
792- String string = "foo" + (char )0x00 + "bar" ;
793+ String string = "foo" + (char ) 0x00 + "bar" ;
793794 client ().prepareIndex (INDEX , TYPE , "1" ).setSource (jsonBuilder ()
794795 .startObject ().startObject (FIELD )
795796 .startArray ("input" ).value (string ).endArray ()
796797 .field ("output" , "foobar" )
797798 .endObject ().endObject ()
798799 ).setRefresh (true ).get ();
799-
800+
800801 }
801-
802+
802803 private static String replaceReservedChars (String input , char replacement ) {
803804 char [] charArray = input .toCharArray ();
804805 for (int i = 0 ; i < charArray .length ; i ++) {
0 commit comments