Buggy code:
@ Service public class AutosuggestService extends BasicService { private static final Logger log = Logger . getLogger ( ImageService . class ) ; public AutosuggestService ( String solrUrl ) { } public String getAutosuggest ( String term , AutosuggestTypes type , String stage , String imagingMethod , String taxon , String sampleType , String imageGeneratedBy , Integer rows ) { SolrQuery solrQuery = new SolrQuery ( ) ; ArrayList < String > suggestions = new ArrayList < > ( ) ; solrQuery . setQuery ( term ) ; solrQuery . setFields ( TERM_AUTOSUGGEST ) ; solrQuery . set ( "defType" , "edismax" ) ; solrQuery . set ( "group" , true ) ; solrQuery . set ( "group.field" , "term_autosuggest_na" ) ; solrQuery . set ( "qf" , "term_autosuggest<seq2seq4repair_space>term_autosuggest_ws<seq2seq4repair_space>term_autosuggest_e<seq2seq4repair_space>term_autosuggest_na" ) ; <START_BUG> solrQuery . set ( "bq" , ( ( ( ( ( ( ( ( "term_autosuggest_ws:\"" + term ) + "\"^2<seq2seq4repair_space>term_autosuggest_e:\"" ) + term ) + "\"^3<seq2seq4repair_space>term_autosuggest_na:\"" ) + term ) + "\"^4<seq2seq4repair_space>term_autosuggest_ws:\"" ) + term ) + "\"^1" ) ) ; <END_BUG> solrQuery . setRows ( rows ) ; System . out . println ( ( ( ( "Solr<seq2seq4repair_space>URL<seq2seq4repair_space>:<seq2seq4repair_space>" + ( solr . getBaseURL ( ) ) ) + "//select?" ) + solrQuery ) ) ; AutosuggestService . log . info ( ( ( ( "Solr<seq2seq4repair_space>URL<seq2seq4repair_space>in<seq2seq4repair_space>getImages<seq2seq4repair_space>:<seq2seq4repair_space>" + ( solr . getBaseURL ( ) ) ) + "//select?" ) + solrQuery ) ) ; if ( type != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . AUTOSUGGEST_TYPE ) + ":" ) + type ) ) ; } if ( stage != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . STAGE ) + ":" ) + stage ) ) ; } if ( taxon != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . TAXON ) + ":" ) + taxon ) ) ; } if ( sampleType != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . SAMPLE_TYPE ) + ":" ) + sampleType ) ) ; } if ( imagingMethod != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . IMAGING_METHOD ) + ":" ) + imagingMethod ) ) ; } if ( imageGeneratedBy != null ) { solrQuery . addFilterQuery ( ( ( ( AutosuggestDTO . IMAGE_GENERATED_BY ) + ":" ) + imageGeneratedBy ) ) ; } try { List < Group > groups = solr . query ( solrQuery ) . getGroupResponse ( ) . getValues ( ) . get ( 0 ) . getValues ( ) ; for ( Group group : groups ) { suggestions . add ( group . getGroupValue ( ) ) ; } } catch ( SolrServerException e ) { e . printStackTrace ( ) ; } JSONObject returnObj = new JSONObject ( ) ; returnObj . put ( "response" , new JSONObject ( ) . put ( "suggestions" , new JSONArray ( suggestions ) ) ) ; return returnObj . toString ( ) . replaceAll ( "<\\\\" , "<" ) ; } public void addBean ( AutosuggestDTO doc ) { } public void addBeans ( Collection < AutosuggestDTO > docs ) { } public void clear ( ) throws IOException , SolrServerException { } }

Fix:
solrQuery . set ( "bq" , ( ( ( ( ( ( ( ( "term_autosuggest_ws:\"" + term ) + "\"^2<seq2seq4repair_space>term_autosuggest_e:\"" ) + term ) + "\"^3<seq2seq4repair_space>term_autosuggest_na:\"" ) + term ) + "\"^4<seq2seq4repair_space>term_autosuggest:\"" ) + term ) + "\"^1" ) ) ;