sunburnt icon indicating copy to clipboard operation
sunburnt copied to clipboard

Support result grouping

Open divideby0 opened this issue 14 years ago • 5 comments

Solr 3.3 added support for result grouping such that results can be returned hierarchically grouped by a common field value like so:

major_value: a
   major_value: a, minor_value: 1
   major_value: a, minor_value: 2
   major_value: a, minor_value: 3
major_value: b
   major_value: b, minor_value: 4
   major_value: b, minor_value: 5

This functionality is particularly useful in retail searching where there are a number of "SKU"s (Red Mens Small, Blue Womens Medium) under a particular "product" (Awesome T-shirt #4).

I added support for this functionality to sunburnt such that you can call:

resp = s.query().group_by('major_value', limit=10).execute()

and get back a list of groupings as resp.result.groups:

for major_value. docs in resp.result.groups:
  print("major_value: %s, # of docs: %s" % (major_value, len(docs))
  for doc in docs:
    print("  major_value: %s, minor_value: %s" % (doc['major_value'], doc['minor_value'])

which yields:

major_value: a, # of docs: 3
   major_value: a, minor_value: 1
   major_value: a, minor_value: 2
   major_value: a, minor_value: 3
major_value: b, # of docs: 2
   major_value: b, minor_value: 4
   major_value: b, minor_value: 5

A screencast detailing the enhancements and usage will be made available shortly.

divideby0 avatar Jul 25 '11 05:07 divideby0

Bump :D

Would be way cool to see this merged into master. Any thoughts, @tow?

vreon avatar Nov 29 '11 18:11 vreon

Just a side-note, there's a new feature in Solr 3.4 that I'd also eventually like to roll in, post-grouping facet counts. I plan to get to this by the end of the year, but in the meantime a merge or feedback on a merge on what's here would be super-helpful.

divideby0 avatar Nov 29 '11 18:11 divideby0

Sorry - have been busy recently!

I haven't had a chance to look at this properly; however what would make it much easier for me to check & merge is a) docs and b) tests.

I'm aiming to do a big merge & release in the next week or two, but nothing will get pulled in until it's fully documented & tested - there's more chance of something getting in quickly if it comes with docs & tests already attached!

tow avatar Nov 29 '11 22:11 tow

Has anything more happened here?

denizdogan avatar Dec 04 '13 20:12 denizdogan

This is many years old, but did anybody ever pursue this PR? @divideby0 do you have a fork somewhere with this?

mlissner avatar Sep 10 '16 01:09 mlissner