@ SuppressWarnings ( "unchecked" ) private void mergeNamedList ( ShardRequest sreq , NamedList < Object > mtasResponse , String key , Integer preferredPurpose ) { // create new response for key NamedList < Object > mtasListResponse ; Object o = mtasResponse . get ( key ) ; if ( o instanceof NamedList ) { mtasListResponse = ( NamedList < Object > ) o ; } else { mtasListResponse = new SimpleOrderedMap <> ( ) ; mtasResponse . removeAll ( key ) ; mtasResponse . add ( key , mtasListResponse ) ; } // collect responses for each shard HashMap < String , NamedList < Object > > mtasListShardResponses = new HashMap <> ( ) ; for ( ShardResponse response : sreq . responses ) { // only continue if new shard or preferred purpose if ( mtasListShardResponses . containsKey ( response . getShard ( ) ) && ( ( preferredPurpose == null ) || ( sreq . purpose != preferredPurpose ) ) ) { break ; } // update try { NamedList < Object > result = response . getSolrResponse ( ) . getResponse ( ) ; NamedList < Object > data = ( NamedList < Object > ) result . findRecursive ( "mtas" , key ) ; if ( data != null ) { mtasListShardResponses . put ( response . getShard ( ) , MtasSolrResultUtil . decode ( data ) ) ; } } catch ( ClassCastException e ) { log . debug ( e ) ; } } try { for ( NamedList < Object > mtasListShardResponse : mtasListShardResponses . values ( ) ) { mergeResponsesNamedList ( mtasListResponse , mtasListShardResponse ) ; } } catch ( IOException e ) { log . error ( e ) ; } }
Merge named list .