Skip to content

Instantly share code, notes, and snippets.

@tomgullo
Created September 25, 2013 17:44
Show Gist options
  • Select an option

  • Save tomgullo/6703282 to your computer and use it in GitHub Desktop.

Select an option

Save tomgullo/6703282 to your computer and use it in GitHub Desktop.
pivot_solr.groovy
.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