lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Hill <jayallenh...@gmail.com>
Subject SolrJ: Setting multiple parameters
Date Sun, 20 Jun 2010 19:12:01 GMT
Working with SolrJ I'm doing a query using the StatsComponent, and the
stats.facet parameter. I'm not able to set multiple fields for the
"stats.facet" parameter using SolrJ. Here is the query I'm trying to create:

http://localhost:8983/solr/select/?q=*:*&stats=on&stats.field=fieldForStats&stats.facet=fieldA&stats.facet=fieldB&stats.facet=fieldC

This works perfectly, and I'm able to pull the "sum" value from all three
stats.facet fields, no problem.

Trying in SolrJ I have this:
  SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery("*:*");

    solrQuery.setParam("stats", "on");
    solrQuery.setParam("stats.field", "fieldForStats");
*    solrQuery.setParam("stats.facet", "fieldA");
    solrQuery.setParam("stats.facet", "fieldB");
    solrQuery.setParam("stats.facet", "fieldC");*

But when I try to retrieve the "sum" values, it seems as if only the LAST
setParam I called on "stats.facet" is taking. So in this case I can get the
sum for fieldC, but not the other two:

//works
      Map<String, FieldStatsInfo> statsInfoMap =
queryResponse.getFieldStatsInfo();
      FieldStatsInfo roomCountElement = statsInfoMap.get("fieldForStats");

      ArrayList fsi = (ArrayList) roomCountElement.getFacets().get("field*C*
");
      for (int i = 0; i < fsi.size(); i++) {

        FieldStatsInfo m = (FieldStatsInfo) fsi.get(i);
        System.out.println("--> " + m.getName() + "   ---------------- " +
m.getSum());

      }

//doesn't work, get a null pointer as "fieldB" doesn't seem to have been
passed to "stats.facet"
      Map<String, FieldStatsInfo> statsInfoMap =
queryResponse.getFieldStatsInfo();
      FieldStatsInfo roomCountElement = statsInfoMap.get("fieldForStats");

      ArrayList fsi = (ArrayList) roomCountElement.getFacets().get("field*B*
");
      for (int i = 0; i < fsi.size(); i++) {

        FieldStatsInfo m = (FieldStatsInfo) fsi.get(i);
        System.out.println("--> " + m.getName() + "   ---------------- " +
m.getSum());

      }

Is there a way to set multiple values for "stats.facet" using the "setParm"
method?  I noticed that there is a "setGetFieldStatistics" method which can
be used to set the stats.field, but there don't seem to be any methods that
reach as deep as setting the stats.facet.

Thanks,
-Jay

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message