On Thu, Mar 13, 2014 at 10:41 AM, Marius Dumitru Florea <mariusdumitru.flo...@xwiki.com> wrote: > Hi guys, > > The following code > > server.queryAndStreamResponse(new SolrQuery("*:*"), new > StreamingResponseCallback() { > public void streamSolrDocument(SolrDocument doc) { > } > public void streamDocListInfo(long numFound, long start, Float maxScore) { > } > }); > > throws > > Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be > cast to java.lang.String > at > org.apache.solr.common.util.JavaBinCodec.readOrderedMap(JavaBinCodec.java:124) > at org.apache.solr.common.util.JavaBinCodec.readVal(JavaBinCodec.java:188) > at > org.apache.solr.common.util.JavaBinCodec.unmarshal(JavaBinCodec.java:116) > at > org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:205) > ... 10 more > > streamDocListInfo and streamSolrDocument are called as expected but > the exception is thrown after all the results are streamed, when > building the QueryResponse to return (which is not really needed). > > I debugged a bit and it fails while unmarshaling: > > { > responseHeader = { > status = 0, > QTime = 1716, > params = { > q = *:*, > fl = name,space,wiki,doclocale, > fq = type:DOCUMENT, > rows = 100, > start = 0 > } > }, > response = { > numFound=571, > start=0, > maxScore = 1.0, > docs=[] > },
> --> here it throws an exception because it expects a String key, but > it gets an array.. After more debugging I found that what the missing part here that fails to be unmarshaled is facet_counts = { facet_queries = {}, facet_fields = {wiki={},space_exact={},locale={}, ...}, facet_dates = {}, facet_ranges = {} }, highlighting = {foo={},bar={}} So this part gets broken in the marshaling / unmarshaling process when streaming the query results. I disabled the faceting and highlighting and no more exception. Note that first I tried to disable the faceting and highlighting by calling: query.setFacet(false); query.setHighlight(false); which didn't work because these calls only remove the faceting and highlighting parameters from the query and I had the faceting and highlighting enabled by default in the Solr configuration. I find this methods confusing. In the end I used: query.set("facet", false); query.set("hl", false); which did the trick. Thankfully I don't need faceting nor highlighting in my case but this ClassCastException thrown when streaming the query results surely looks like a bug. Can you reproduce? Thanks, Marius > } > > Note that on my project I have two branches > > * one using Solr 4.0.0 and Java 1.6 > * one using Solr 4.7.0 and Java 1.7 > > Both produce the same exception. Do you know what could be wrong? > > Thanks, > Marius