yuanyun.cn created SOLR-4240:
--------------------------------

             Summary: Stats response always shows one extra empty facets 
element in Solr 4.0. 
                 Key: SOLR-4240
                 URL: https://issues.apache.org/jira/browse/SOLR-4240
             Project: Solr
          Issue Type: Bug
          Components: SearchComponents - other
            Reporter: yuanyun.cn
            Priority: Minor
             Fix For: 4.1



If I don't specify stats.facet, it still shows one extra facets element. 
http://localhost:8888/solr/select?q=*:*&rows=0&stats=true&stats.field=szkb
{code:xml} 
<lst name="stats">
        <lst name="stats_fields">
                <lst name="szkb">
                        <double name="min">1.0</double>
                        <double name="max">3.0</double>
                        <long name="count">4980</long>
                        <long name="missing">0</long>
                        <double name="sum">10369.0</double>
                        <double name="sumOfSquares">22637.0</double>
                        <double name="mean">2.082128514056225</double>
                        <double name="stddev">0.4586561046404609</double>
                        <lst name="facets"/> ===> extra facets elment
                </lst>
        </lst>
</lst>
{code} 
If I specify stats.facet, then for each facet value, it shows one extra facets 
element. 
http://localhost:8888/solr/select?q=*:*&rows=0&stats=true&stats.field=szkb&stats.facet=filetype
{code:xml} 
<lst name="facets">
        <lst name="filetype">
                <lst name="ppt">
                        <double name="min">1.0</double>
                        <double name="max">1.0</double>
                        <long name="count">1</long>
                        <long name="missing">0</long>
                        <double name="sum">1.0</double>
                        <double name="sumOfSquares">1.0</double>
                        <double name="mean">1.0</double>
                        <double name="stddev">0.0</double>
                        <lst name="facets"/> ===> extra facets elment, this is 
bad.
                </lst>
        </lst>
</lst>
{code} 
The empty facets elment is no use, and annoying.

The culprit is the code:
org.apache.solr.handler.component.AbstractStatsValues.getStatsValues()
{code:title=StatsValuesFactory.java|borderStyle=solid}
public NamedList<?> getStatsValues() {
 // add the facet stats
 ===> Here it always adds facets, in stead, it should check whether it is 
empty: if (!facets.isEmpty())
NamedList<NamedList<?>> nl = new SimpleOrderedMap<NamedList<?>>();
for (Map.Entry<String, Map<String, StatsValues>> entry : facets.entrySet()) {
  NamedList<NamedList<?>> nl2 = new SimpleOrderedMap<NamedList<?>>();
  nl.add(entry.getKey(), nl2);
  for (Map.Entry<String, StatsValues> e2 : entry.getValue().entrySet()) {
        nl2.add(e2.getKey(), e2.getValue().getStatsValues());
  }
}
res.add(FACETS, nl);
return res;
}
{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