Konrad Cerny
Konrad Cerny

Reputation: 200

SOLR: how to get all values of grouped results

I'm using SOLR 4.7.x. I need help with this simple task. Here's my data:

=======================
| Id | Code | Faculty |
=======================
| 1  | UK   | A |
| 2  | UK   | B |
...
| 10 | CVUT | K |
| 11 | CVUT | L |
| 12 | CVUT | M |
...

and when I'm grouping by code, the result is correct, but I need to get the list (for example concatenated with '|') like:

groups : [
    {
        doclist: {
            numFound: 2,
            docs: [
                {
                    id: 1,
                    code: UK,
                    faculty: A,
                    groupConcatenated: A|B,
                }
            ]
        }
    },
    {
        doclist: {
            numFound: 3,
            docs: [
                {
                    id: 10,
                    code: CVUT,
                    faculty: K,
                    groupConcatenated: K|L|M,
                }
            ]
        }
    }
]

Simply I need to see what is grouped...

In PostgreSQL it's as simple as: array_to_string(array_agg(faculty), ',') as groupConcatenated

Upvotes: 1

Views: 165

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

You're probably looking for Pivot Faceting, which will allow you to get the count of each unique value for each step in the hierarchy.

&facet=true&facet.pivot=code,Faculty

Upvotes: 1

Related Questions