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 Dawe <da...@centrum.cz> on 2008/04/14 18:14:39 UTC

Count of facet count

Hello,

how I can get count of distinct facet_fields ?

like numFacetFound in this example:

http://localhost:8983/solr/select?q=xxx&rows=0&facet=true&facet.limit=10&facet.field=county

<response>
<responseHeader><status>0</status><QTime>2</QTime></responseHeader>
<result numFound="10" start="0"/>
<lst name="facet_counts">
 <lst name="facet_queries"/>
 <lst name="facet_fields">
  <lst name="county" numFacetFound="4" >
        <int name="Prague">3</int>
        <int name="Berlin">1</int>
        <int name="Amsterdam">1</int>
        <int name="Madrid">5</int>
  </lst>
 </lst>
</lst>
</response>

Thanks
-- 
View this message in context: http://www.nabble.com/Count-of-facet-count-tp16678811p16678811.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Count of facet count

Posted by "Karsten F." <ka...@fiz-technik.de>.
Hi,

Some questions about an integer with numFacetFound for facets in solr:

Our application "tecfinder" has a faceted browsing with paging for each
facet 
(see "Fachgebiete" in
http://tecfinder.fiz-technik.de/tecfinder/faces/facelets/search/search.jsp?query=Laser
).
Currently I am integrating solr in "tecfinder". So I need the number of
terms that have a non zero count.
e.g. if I search with
facet=true&facet.field=LG&f.LG.facet.limit=4
we need something like numFacetFound=19 for field LG (see example below).

To program an addition for SimpleFacets should be easy,
because I only have to change three methods:
 - getFacetTermEnumCounts (with respect to the line "if (--lim<0) break;")
 - getFieldCacheCounts (count non zero values of "int[] counts")
 - UnInvertedField.getCounts (again "int[] counts")

It will not be easy to change DistribFieldFacet, but I hope this can wait
("This API is experimental and subject to change").

So my questions:
Is there already an "numFacetFound" addition programed for solr?
 
Did I miss something? Is there more to change then this three methods?

What is an accurate place to expand the response with "numFacetFound"?
(Should I derive a subclass "SubList" or "OffsetList" of NamedList with an
attribute "totalAmount").

Any advice is welcome

  Karsten

p.s. the example for
facet=true&facet.field=LG&f.LG.facet.limit=4

<result name="response" numFound="18614" start="0">
<lst name="facet_counts">
  <lst name="facet_queries"/>
    <lst name="facet_fields">
      <lst name="LG">
        <int name="_numFacetFound">19</int>
        <int name="ru">592</int>
        <int name="fr">191</int>
        <int name="ja">82</int>
        <int name="pl">32</int>
      </lst>
    </lst>
  <lst name="facet_dates"/>
</lst>
</response> 


hossman wrote:
> 
> 
> : > : how I can get count of distinct facet_fields ?
> : > : 
> : > : like numFacetFound in this example:
> : > 
> : > There's currently no way to do that.
> 
> : I need to do the same thing. Any pointers on how one would go about
> : implementing that? (in Java) Thanks.
> 
> The change would be in the SimpleFacets class, and there are a couple of 
> differnet code paths to worry about (because two different hueristics are 
> used depending on the field type) but the first step would be to define 
> what the count represents: is it just the number of terms being returned? 
> the number of terms that have a non zero count? or all of the terms in the 
> field?
> 
> the first and the last are pretty trivial, the middle one requires 
> maintaining a new count as the terms are scanned (and if i'm not mistaken, 
> there's an optimization in there to stop once we know we won't find any 
> terms better then theones we already have, and in order to return that 
> count you'd need to prevent that optimization)
> 
> 
> -Hoss
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Count-of-facet-count-tp16678811p24052214.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Count of facet count

Posted by Chris Hostetter <ho...@fucit.org>.
: > : how I can get count of distinct facet_fields ?
: > : 
: > : like numFacetFound in this example:
: > 
: > There's currently no way to do that.

: I need to do the same thing. Any pointers on how one would go about
: implementing that? (in Java) Thanks.

The change would be in the SimpleFacets class, and there are a couple of 
differnet code paths to worry about (because two different hueristics are 
used depending on the field type) but the first step would be to define 
what the count represents: is it just the number of terms being returned? 
the number of terms that have a non zero count? or all of the terms in the 
field?

the first and the last are pretty trivial, the middle one requires 
maintaining a new count as the terms are scanned (and if i'm not mistaken, 
there's an optimization in there to stop once we know we won't find any 
terms better then theones we already have, and in order to return that 
count you'd need to prevent that optimization)


-Hoss


Re: Count of facet count

Posted by terhorst <te...@gmail.com>.


hossman wrote:
> 
> 
> : how I can get count of distinct facet_fields ?
> : 
> : like numFacetFound in this example:
> 
> There's currently no way to do that.
> 
> 
> -Hoss
> 
> 
> 

I need to do the same thing. Any pointers on how one would go about
implementing that? (in Java) Thanks.
-- 
View this message in context: http://www.nabble.com/Count-of-facet-count-tp16678811p18912587.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Count of facet count

Posted by Chris Hostetter <ho...@fucit.org>.
: how I can get count of distinct facet_fields ?
: 
: like numFacetFound in this example:

There's currently no way to do that.


-Hoss