public FrontierQuery buildFrontierQuery(BytesRefHash collectorTerms,Integer frontierSize){
  if (collectorTerms == null || collectorTerms.size() == 0) {
    return null;
  }
 else {
    Query q=null;
    if (useAutn) {
      Automaton autn=buildAutomaton(collectorTerms);
      AutomatonQuery autnQuery=new AutomatonQuery(new Term(fromField),autn);
      q=autnQuery;
    }
 else {
      List<BytesRef> termList=new ArrayList<>(collectorTerms.size());
      for (int i=0; i < collectorTerms.size(); i++) {
        BytesRef ref=new BytesRef();
        collectorTerms.get(i,ref);
        termList.add(ref);
      }
      q=new TermsQuery(fromField,termList);
    }
    if (traversalFilter != null) {
      BooleanQuery.Builder builder=new BooleanQuery.Builder();
      builder.add(q,Occur.MUST);
      builder.add(traversalFilter,Occur.MUST);
      q=builder.build();
    }
    FrontierQuery frontier=new FrontierQuery(q,frontierSize);
    return frontier;
  }
}

public FrontierQuery buildFrontierQuery ( BytesRefHash collectorTerms , Integer frontierSize ) { if ( collectorTerms == null || collectorTerms . size ( ) == 0 ) { return null ; } else { Query q = null ; if ( useAutn ) { Automaton autn = buildAutomaton ( collectorTerms ) ; AutomatonQuery autnQuery = new AutomatonQuery ( new Term ( fromField ) , autn ) ; q = autnQuery ; } else { List < BytesRef > termList = new ArrayList < > ( collectorTerms . size ( ) ) ; for ( int i = 0 ; i < collectorTerms . size ( ) ; i ++ ) { BytesRef ref = new BytesRef ( ) ; collectorTerms . get ( i , ref ) ; termList . add ( ref ) ; } q = new TermsQuery ( fromField , termList ) ; } if ( traversalFilter != null ) { BooleanQuery . Builder builder = new BooleanQuery . Builder ( ) ; builder . add ( q , Occur . MUST ) ; builder . add ( traversalFilter , Occur . MUST ) ; q = builder . build ( ) ; } FrontierQuery frontier = new FrontierQuery ( q , frontierSize ) ; return frontier ; } }
this return a query that represents the documents that match the next hop in the query . collectorterms - the terms that represent the edge ids for the current frontier . frontiersize - the size of the frontier query ( number of unique edges )
