lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Jelsma <>
Subject JSON facets, count a long or an integer in cloud and non-cloud modes
Date Tue, 22 Mar 2016 08:46:52 GMT

Using SolrJ i built a method that consumes output produced by JSON facets, it also checks
the count before further processing the output:

<result name="response" numFound="49" start="0">
<lst name="facets">
  <int name="count">49</int>
  <lst name="by_day">
    <arr name="buckets">

This is the code reading the count value via SolrJ:

    QueryResponse response = sourceClient.query(query);
    NamedList jsonFacets = (NamedList)response.getResponse().get("facets");
    int totalOccurences = (int)jsonFacets.get("count");

The problem is, this code doesn't work in unit tests, it throws a:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer!?

But why it is an integer right? Anyway, i change the totalOccurences and the cast to a long
and the unit tests runs just fine. But when actually running the code, i suddenly get another
cast exception at exactly the same line.
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

What is going on? The only difference is that the unit tests runs in cloud mode via AbstractFullDistribZkTestBase,
but i run the code in a local dev non-cloud mode. I haven't noticed this behaviour anywhere
else although i have many unit tests consuming lots of different pieces of Solr output, and
all that code runs fine in non-cloud mode too.

Is this to be expected, normal? Did i catch another bug?


View raw message