sequence/xjoin/src/main/java/org/apache/solr/search/xjoin/XJoinSearchComponent.java
/**
   * Match up search results and add corresponding data for each result (if we have query
   * results available).
   */
Match up search results and add corresponding data for each result (if we have query
results available).
Match up search results and add corresponding data for each result ( if we have query results available ) .
@Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public void process(ResponseBuilder rb) throws IOException {
    SolrParams params = rb.req.getParams();
    if (! params.getBool(getName(), false)) {
      return;
    }
    XJoinResults<?> results = (XJoinResults<?>)rb.req.getContext().get(getResultsTag());
    if (results == null || rb.getResults() == null) {
      return;
    }
    FieldAppender appender = new FieldAppender((String)params.get(getName() + "." + XJoinParameters.RESULTS_FIELD_LIST, "*"));
    NamedList general = appender.addNamedList(rb.rsp.getValues(), getName(), results);
    FieldAppender docAppender = new FieldAppender((String)params.get(getName() + "." + XJoinParameters.DOC_FIELD_LIST, "*"));    
    Set<String> joinFields = new HashSet<>();
    joinFields.add(joinField);
    List<String> joinIds = new ArrayList<>();
    for (Iterator<Integer> it = docIterator(rb); it.hasNext(); ) {
      Document doc = rb.req.getSearcher().doc(it.next(), joinFields);
      for (String joinId : doc.getValues(joinField)) {
        if (! joinIds.contains(joinId)) {
          joinIds.add(joinId);
        }
      }
    }
    List externalList = new ArrayList();
    general.add("external", externalList);
    for (String joinId : joinIds) {
      Object object = results.getResult(joinId);
      if (object == null) continue;
      SimpleOrderedMap external = new SimpleOrderedMap<>();
      externalList.add(external);
      external.add("joinId", joinId);
      if (object instanceof Iterable) {
        for (Object item : (Iterable)object) {
          docAppender.addNamedList(external, "doc", item);
        }
      } else {
        docAppender.addNamedList(external, "doc", object);        
      }
    }
  }
@ Override @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public void process ( ResponseBuilder rb ) throws IOException { SolrParams params = rb . req . getParams ( ) ; if ( ! params . getBool ( getName ( ) , false ) ) { return ; } XJoinResults < ? > results = ( XJoinResults < ? > ) rb . req . getContext ( ) . get ( getResultsTag ( ) ) ; if ( results == null || rb . getResults ( ) == null ) { return ; } FieldAppender appender = new FieldAppender ( ( String ) params . get ( getName ( ) + "." + XJoinParameters . RESULTS_FIELD_LIST , "*" ) ) ; NamedList general = appender . addNamedList ( rb . rsp . getValues ( ) , getName ( ) , results ) ; FieldAppender docAppender = new FieldAppender ( ( String ) params . get ( getName ( ) + "." + XJoinParameters . DOC_FIELD_LIST , "*" ) ) ; Set < String > joinFields = new HashSet < > ( ) ; joinFields . add ( joinField ) ; List < String > joinIds = new ArrayList < > ( ) ; for ( Iterator < Integer > it = docIterator ( rb ) ; it . hasNext ( ) ; ) { Document doc = rb . req . getSearcher ( ) . doc ( it . next ( ) , joinFields ) ; for ( String joinId : doc . getValues ( joinField ) ) { if ( ! joinIds . contains ( joinId ) ) { joinIds . add ( joinId ) ; } } } List externalList = new ArrayList ( ) ; general . add ( "external" , externalList ) ; for ( String joinId : joinIds ) { Object object = results . getResult ( joinId ) ; if ( object == null ) continue ; SimpleOrderedMap external = new SimpleOrderedMap < > ( ) ; externalList . add ( external ) ; external . add ( "joinId" , joinId ) ; if ( object instanceof Iterable ) { for ( Object item : ( Iterable ) object ) { docAppender . addNamedList ( external , "doc" , item ) ; } } else { docAppender . addNamedList ( external , "doc" , object ) ; } } }
Match up search results and add corresponding data for each result (if we have query
 results available).
Match up search results and add corresponding data for each result ( if we have query results available ) .
// general results // per join id results