Say I indexed the following from my database:
======================================
| Id | Code | Description |
======================================
| 1 | A1 | Hello world |
| 2 | A1 | Hello world 123 |
| 3 | A1 | World hello hi |
| 4 | B1 | Quick fox jumped |
| 5 | B1 | Lazy dog |
...
Further, say the user searches for "hello", which should return records 1, 2, and 3. Is there a way to make Solr "group by" the Code
field and apply a limit (say, 10 records)? I'm somewhat looking for a SQL counterpart of GROUP BY and LIMIT.
Also, when it does this "group by", I want it to choose the most relevant document and use that document's Description
field as part of the return.
Of course, I could just have Solr return everything to my application and I can manipulate the results to do the GROUP BY and LIMIT. I'd rather not do this if possible.