private function buildFacetsArray($facetsJson) {
        foreach($facetsJson as $facetObj) {
            //build array of term with <term> => <number of occurences>
            $terms = array();
            foreach($facetObj->terms as $termObj) {
                $terms[$termObj->term] = $termObj->count;
            }
            $this->facets[$facetObj->fieldName] = $terms;
        }
    }