how to extract stats component with solrj 4.9.0

2014-07-26 Thread Edith Au
I have a solr query like this

q=categories:cat1 OR
categories:cat2&stats=true&stats.field=count&stats.facet=block_num

Basically, I want to get the sum(count) group by block num.


This query works on a browser. But with solrj, I could not access the stats
fields from the Response obj. I can do a response.getFieldStatsInfo(). But
it is not what I want. Here is how I construct the query

SolrQuery query = new SolrQuery(q);
query.add("stats", "true");
query.add("stats.field", "count");
query.add("stats.facet", "block_num");

With a debugger, I could see that the response has a private statsInfo
object and it has the information I am looking for. But there is no api to
access the private object.

I would like to know if there is

   1. a better way to construct my query. I only need the sum of (count),
   group by block num
   2. a way to access the hidden statsInfo object in the query response()?
   [it is so frustrated. I can see all the info I need in the private obj on
   my debugger!]

Thanks!


ps. I posted this question on stackoverflow but have gotten no response so
far.  Any help will be greatly appreciated!

Thanks!


Re: how to extract stats component with solrj 4.9.0

2014-07-28 Thread Edith Au
I tried getFieldStatsInfo().  I got a stats of the stats with this method
(ie. sum (sum(count)) of all the group'ed results.  But it is not what I
want.  I want a list of stats (ie. sum(count), group by block num).  With a
debugger, I could see the information I want in this private object
response._statsInfo.

I could grab the information I want with response.toString().  That's what
I did and parse the string myself for now. :(




On Sun, Jul 27, 2014 at 1:41 PM, Erick Erickson 
wrote:

> Have you tried the getFieldStatsInfo method in the QueryResponse object?
>
> Best,
> Erick
>
>
> On Sat, Jul 26, 2014 at 3:36 PM, Edith Au  wrote:
>
> > I have a solr query like this
> >
> > q=categories:cat1 OR
> > categories:cat2&stats=true&stats.field=count&stats.facet=block_num
> >
> > Basically, I want to get the sum(count) group by block num.
> >
> >
> > This query works on a browser. But with solrj, I could not access the
> stats
> > fields from the Response obj. I can do a response.getFieldStatsInfo().
> But
> > it is not what I want. Here is how I construct the query
> >
> > SolrQuery query = new SolrQuery(q);
> > query.add("stats", "true");
> > query.add("stats.field", "count");
> > query.add("stats.facet", "block_num");
> >
> > With a debugger, I could see that the response has a private statsInfo
> > object and it has the information I am looking for. But there is no api
> to
> > access the private object.
> >
> > I would like to know if there is
> >
> >1. a better way to construct my query. I only need the sum of (count),
> >group by block num
> >2. a way to access the hidden statsInfo object in the query
> response()?
> >[it is so frustrated. I can see all the info I need in the private obj
> > on
> >my debugger!]
> >
> > Thanks!
> >
> >
> > ps. I posted this question on stackoverflow but have gotten no response
> so
> > far.  Any help will be greatly appreciated!
> >
> > Thanks!
> >
>


Re: how to extract stats component with solrj 4.9.0

2014-07-28 Thread Edith Au
Thanks Shawn.


I found this method FieldStatsInfo().getFacets() in the Solr 4.9.0 doc.
 But it seems to me the method is missing in my Solrj 4.9.0 distribution.
 Could this be a bug?  or I have a bad distro?






On Mon, Jul 28, 2014 at 9:43 AM, Shawn Heisey  wrote:

> On 7/28/2014 10:08 AM, Edith Au wrote:
> > I tried getFieldStatsInfo().  I got a stats of the stats with this method
> > (ie. sum (sum(count)) of all the group'ed results.  But it is not what I
> > want.  I want a list of stats (ie. sum(count), group by block num).
>  With a
> > debugger, I could see the information I want in this private object
> > response._statsInfo.
> >
> > I could grab the information I want with response.toString().  That's
> what
> > I did and parse the string myself for now. :(
>
> Edith,
>
> Everything that's in the QueryResponse is available as a Java object,
> with getHeader and getResponse being the gateways.  The NamedList object
> type that these methods return is a very compact and useful structure,
> created specifically for Solr.  Once you have a NamedList, the data that
> you want might be buried, so the findRecursive method (available with
> SolrJ 4.4.0 and later) can be very useful to navigate the object easily.
>
> Thanks,
> Shawn
>
>