d-_-b
d-_-b

Reputation: 23151

SOLR stats facet return non-facet count total

I'm using SOLR to store music playback information

when i do a query (broken out for readability):

http://localhost:8983/solr/select/
                                  ?q=song_1:*
                                   &stats=true
                                   &stats.field=song_2
                                   &stats.field=song_3
                                   &rows=0

I'm trying to see, of the people that played song_1, how many also played the other songs.

question: How can I also return the totals for each stats.field regardless of my query song_1?

In other words, I already get the coun tof people that played song_1 and song_2, but how can I add how many played song_2, regardless of song_1.

<response>
<result name="response" numFound="5454" start="0"></result>
<lst name="stats">
  <lst name="stats_fields">
    <lst name="song_2">
      <str name="min">4</str>
      <str name="max">1500</str>
      <long name="count">2000</long>
      <long name="missing">3454</long>
    <lst name="facets"/>
   </lst>
<lst name="song_3">
  <str name="min">10</str>
  <str name="max">1500</str>
  <long name="count">200</long>
  <long name="missing">3454</long>
  <lst name="facets"/>
</lst> 
</response>

Upvotes: 0

Views: 161

Answers (1)

Jayesh Bhoyar
Jayesh Bhoyar

Reputation: 727

I don't know why you are using the stats query.

If your requirement is to see how many people have listened to song_1 and also you want to see how many people has listened to other songs..

Then you should used faceted search.

Check the following thing for more explanation:

http://technical-fundas.blogspot.in/2014/08/solr-implementing-facet-with-multiple.html

Hope this helps you in resolving this issue!!!

Upvotes: 1

Related Questions