Created
September 25, 2013 17:44
-
-
Save tomgullo/6703282 to your computer and use it in GitHub Desktop.
pivot_solr.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .setParam('facet.pivot', 'one,two') | |
| org.apache.solr.common.util.NamedList pivots = resp?.response?.facet_counts?.facet_pivot | |
| def pivot = pivots.get('one,two') | |
| def m = ['name':'root'] | |
| m['children'] = [] | |
| { | |
| def inner_l = [] | |
| for (e2 in e.pivot) { | |
| inner_l << ['name':"${e2.value}", 'size':e2.count] | |
| } | |
| def inner_m = ['name':"${e.value}"] | |
| inner_m['children'] = inner_l ?: [] | |
| } | |
| JSONValue.toJSONString(m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment