0
votes

I am implementing solr. I have a lot of tables in sql server. Now I have created a query which wil give me data from all tables in a flat single table which I will insert into solr. Here is the data I have Categories have multiple packs and packs have multiple assets which are part of single table now in Solr.

The unique key in solr is categoryid, packsid, assetid Now in Solr I need count of packs in cateogries. How can I achieve this in Solr?

What I need is to get all the result with distinct category and packid and then group it by categoryid to get the count of packs in a different categories. How can group the result that is coming from the solr query

This is what I want I have collection of rows where columns are Categoryid, Packid, Description, ImageUrl..... I need to get the distinct rows for combination of Categoryid and Packid. After getting the distinct rows I need to group these distinct rows with Categoryid, imageurl and Description containing count of Packid in it.

2

2 Answers

0
votes

If you are using Solr5, you can make use of subfacetting which is well described by Yonik here:

http://yonik.com/solr-subfacets/

If you are using Solr4 or lower (and of course, also 5), facets are still the way to go. You should start by adding to your requests:

fq=packid:<the selected id>&facet=true&facet.field=categoryid

From there on, you can add tagged parameters to get the counts as you seem fit.

https://wiki.apache.org/solr/SimpleFacetParameters and on this page, especially: tagging and excluding filters

0
votes

I assume you have solr id as catId, packId and asset id. Also along with the details in id, you should also have then as part of you fields and with denormalization in effect, you can query with multiple fields like catId and packId and then facet on multiple fields to get count for each combination. You can do faceting with two fields. Let me know if this approach can fit your need