public static String cleanFieldName ( String name ) { String lowercase = name . toLowerCase ( ) ; lowercase = lowercase . replaceAll ( "[^a-z_0-9]" , "_" ) ; if ( lowercase . length ( ) < 3 || lowercase . length ( ) > 64 ) throw new RuntimeException ( "Field name must be between 3 and 64 chars : " + lowercase ) ; if ( lowercase . equals ( "score" ) ) throw new RuntimeException ( "Field name must be score" ) ; return lowercase ; }
Remove the non - cloudSearch - legal characters . Note that this might convert two fields to the same name .