def pivot_query(facet=None, facet_pivot_fields=None, **kwargs):
    """
    Pivot query
    """
    if facet_pivot_fields is None:
        facet_pivot_fields = []
    results = search_associations(rows=0,
                                  facet_fields=[facet],
                                  #facet_pivot_fields=facet_pivot_fields + [facet],
                                  facet_pivot_fields=facet_pivot_fields,
                                  **kwargs)
    return results
Pivot query