public static List < FacetQueryResult . Field > convert ( QueryResponse solrResponse , Map < String , String > alias ) { // Sanity check if ( solrResponse == null || solrResponse . getResponse ( ) == null || solrResponse . getResponse ( ) . get ( "facets" ) == null ) { return null ; } if ( alias == null ) { alias = new HashMap <> ( ) ; } SimpleOrderedMap < Object > solrFacets = ( SimpleOrderedMap < Object > ) solrResponse . getResponse ( ) . get ( "facets" ) ; List < FacetQueryResult . Field > fields = new ArrayList <> ( ) ; int count = ( int ) solrFacets . get ( "count" ) ; for ( int i = 0 ; i < solrFacets . size ( ) ; i ++ ) { String name = solrFacets . getName ( i ) ; if ( ! "count" . equals ( name ) ) { if ( solrFacets . get ( name ) instanceof SimpleOrderedMap ) { String [ ] split = name . split ( "___" ) ; FacetQueryResult . Field facetField = new FacetQueryResult . Field ( getName ( split [ 0 ] , alias ) , getBucketCount ( ( SimpleOrderedMap < Object > ) solrFacets . get ( name ) , count ) , new ArrayList <> ( ) ) ; if ( split . length > 3 ) { facetField . setStart ( FacetQueryParser . parseNumber ( split [ 1 ] ) ) ; facetField . setEnd ( FacetQueryParser . parseNumber ( split [ 2 ] ) ) ; facetField . setStep ( FacetQueryParser . parseNumber ( split [ 3 ] ) ) ; } parseBuckets ( ( SimpleOrderedMap < Object > ) solrFacets . get ( name ) , facetField , alias ) ; fields . add ( facetField ) ; } else { fields . add ( parseAggregation ( name , solrFacets . get ( name ) , alias ) ) ; } } } return fields ; }
Convert a generic solrResponse into our FacetQueryResult .