You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erik Fäßler <er...@uni-jena.de> on 2012/04/24 17:06:58 UTC

Stats Component and solrj

Hey all,

I'd like to know how many terms I have in a particular field in a search. In other words, I want to know how many facets I have in that field. I use string fields, there are no numbers. I wanted to use the Stats Component and use its "count" value. When trying this out in the browser, everything works like expected.
However, when I want to do the same thing in my Java web app, I get an error because in FieldStatsInfo.class it says

 min = (Double)entry.getValue();

Where 'entry.getValue()' is a String because I have a string field here. Thus, I get an error that String cannot be cast to Double.
In the browser I just got a String returned here, probably relative to an lexicographical order.

I switched the Stats Component on with

query.setGetFieldStatistics("authors");

Where 'authors' is a field with author names.
Is it possible that solrj not yet works with the Stats Component on string fields? I tried Solr 3.5 and 3.6 without success. Is there another easy way to get the count I want? Will solrj be fixed? Or am I just doing an error?

Best regards,

	Erik