2

Using Solr 3.3
Key Store Item Name Description Category Price
=========================================================================
1 Store Name Xbox 360 Nice game machine Electronic Games 199.99
2 Store Name Xbox 360 Nice game machine Electronic Games 199.99
3 Store Name Xbox 360 Nice game machine Electronic Games 249.99

I have data similar to above table and loaded into Solr. Item Name, description Category, Price are searchable.

Expected result

Facet Field         
 Category             
   Electronic(1)   
   Games(1) 

 **Store Name** 
 XBox 360 Nice game machine priced from 199.99 - 249.99

What will be the query parameters that I can send to Solr to receive results above, basically I wan to group it by Store, ItemName, Description and min max price

And I want to keep paging consistent with the main (StoreName). The paging should be based on the Store Name group. So if 20 stores were found. I should be able to correctly page.

Please suggest

ted.strauss
  • 4,119
  • 4
  • 34
  • 57
user357086
  • 404
  • 1
  • 9
  • 23

3 Answers3

8

If using Solr 4.0, the new "Grouping" (which replaces FieldCollapsing) fixes this issue when you add the parameter "group.facet=true".

So to group your fields you would have add the following parameters to your search request:

group=true         // Enables grouping
group.facet=true   // Facet counts to be number of groups instead of documents
group.field=Store  // Groups results by the field "Store"
group.ngroups=true // Tells Solr to return the number of groups found

The number of groups found is what you would show to the user and use for paging, instead of the normal total count, which would be the total number of documents in the index.

David Duffett
  • 3,145
  • 2
  • 26
  • 27
  • `group.facet` is extremely inefficient for indexes about 25M records and a size of 20GB (here, a query without `group.facet` takes about 1-2 seconds, with this option enabled it takes >25 seconds) – rabudde Jul 21 '16 at 12:28
0

Have you looked into field collapsing? It is new in Solr 3.3.

http://wiki.apache.org/solr/FieldCollapsing

jturmel
  • 265
  • 1
  • 3
  • 8
  • I have tried it, but the Facet counts don't come up right. The results count still shows 4 instead of 1, but the results are grouped. Don't know how to make a clean counts of facet, paging etc come out to be right. – user357086 Aug 31 '11 at 02:34
0

What I did is I created another field that grouped the required fields in a single field and stored it, problem solved, so now I just group only on that field and I get the correct count.

user357086
  • 404
  • 1
  • 9
  • 23