I get the class cast exception when trying to run the solrj program using /suggest handler. I am able to get the suggestion response from Solr Admin UI, but when the same is being tried from solrj client the above exception arises.
The solr-config.xml entries are as follows :
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">suggestfield</str>
<str name="suggestAnalyzerFieldType">text_general</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
<str name="suggest.dictionary">mySuggester</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
The schema.xml contains the field
<field name="suggestfield" type="text_general" indexed="true" stored="true"/>
which is a copyField of multiple fields.
The java code is as follows :
String url = "http://localhost:8983/solr/testwidget";
HttpSolrClient client = new HttpSolrClient.Builder(url).build();
client.setParser(new XMLResponseParser());
SolrQuery query = new SolrQuery();
query.setRequestHandler("/suggest");
query.setParam("suggest.build", true);
query.setParam("suggest", true);
query.setParam("suggest.dictionary", "mySuggester");
query.setParam("suggest.q", "acc");
QueryResponse response = client.query(query);
System.out.println(response.getSuggesterResponse().getSuggestedTerms());
The exception is as follows :
Exception in thread "main" java.lang.ClassCastException: org.apache.solr.common.util.SimpleOrderedMap cannot be cast to java.util.Map
at org.apache.solr.client.solrj.response.QueryResponse.setResponse(QueryResponse.java:161)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:194)
at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:942)
at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:957)
at com.intellectdesign.canvas.solr.SolrjTest.main(SolrjTest.java:41)