[ 
https://issues.apache.org/jira/browse/SOLR-5079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720857#comment-13720857
 ] 

Sandro Mario Zbinden edited comment on SOLR-5079 at 7/26/13 3:18 PM:
---------------------------------------------------------------------

I created a first patch that implement this feature and reduce the traffic for 
loading facet pivoting. In this patch there is a disadvantage. If facet.limit 
is not set to -1 the ngroup count is affected.

The main change of the code is that i added the ngroup in the PivotFacetHelper 
class

{code:title=PivotFacetHelper.java|borderStyle=solid}
          boolean ngroups = params.getFieldBool(field, 
FacetParams.FACET_PIVOT_NGROUP, false);
          if (ngroups) {
            int ngroup = 0;
            for (Entry<String,Integer> entry  : nl) {
              if (entry.getValue() > 0) {
                ngroup = ngroup + 1;
              }
            }
            pivot.add("ngroup", ngroup);  
          }
{code}

Further on if a Pivot is set to visible false the recusion will be stopped

{code:title=PivotFacetHelper.java|borderStyle=solid}
          if (nl.size() >= minMatch) {
            boolean visible = params.getFieldBool(subField, 
FacetParams.FACET_PIVOT_VISIBLE, true);
            if (visible) {
              pivot.add( "pivot", doPivots( nl, subField, nextField, fnames, 
subset) );  
            }
            values.add( pivot ); // only add response if there are some counts
          }
{code}

                
      was (Author: sandrozbinden):
    I created a first patch that implement this feature and reduce the traffic 
for loading facet pivoting. In this patch there is a disadvantage. If 
facet.limit is not set to -1 the ngroup count is affected.

The main change of the code is that i added the ngroup in the PivotFacetHelper 
class

{code:title=PivotFacetHelper.java|borderStyle=solid}
          boolean ngroups = params.getFieldBool(field, 
FacetParams.FACET_PIVOT_NGROUP, false);
          if (ngroups) {
            int ngroup = 0;
            for (Entry<String,Integer> entry  : nl) {
              if (entry.getValue() > 0) {
                ngroup = ngroup + 1;
              }
            }
            pivot.add("ngroup", ngroup);  
          }
{code}
                  
> Create ngroups for pivot faceting
> ---------------------------------
>
>                 Key: SOLR-5079
>                 URL: https://issues.apache.org/jira/browse/SOLR-5079
>             Project: Solr
>          Issue Type: Improvement
>    Affects Versions: 5.0, 4.5
>            Reporter: Sandro Mario Zbinden
>              Labels: facet, pivot
>         Attachments: SOLR-5079.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> To save network traffic it would be great to now how many entries a facet 
> list contains without loading the complete facet list. This issue is created 
> because of an out of memory in loading the pivot facet.
> The facet.pivot result would then look like
> q=facet.pivot=cat,id&facet.pivot.ngroup=true
> {code:xml}
> <arr name="cat,id">
>  <lst>
>    <str name="field">cat/str>
>    <str name="value">a</str>
>    <int name="count">20</int>
>    <arr name="pivot">
>    <lst>
>      <str name="field">id</str>
>      <int name="value">69</int>
>      <int name="count">10</int>
>    </lst>
>    <lst>
>      <str name="field">id</str>
>      <int name="value">71</int>
>      <int name="count">10</int>
>    </lst>
>    <int name="ngroup">2</int> <-- The new ngroup parm
>  </lst>
> </arr>
> {code}
> If you add another new param for example facet.pivot.visible the
> result could create less traffic
> especially if there are a lot of ids and the param facet.limit=-1 is set
> q=facet.pivot=cat,id&facet.ngroup=true&f.id.facet.pivot.visible=false
> {code:xml}
> <arr name="cat,id">
>  <lst>
>    <str name="field">cat/str>
>    <str name="value">a</str>
>    <int name="count">20</int>
>    <int name="ngroup">2</int> <-- The new ngroup parm
>  </lst>
> </arr>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to