code: protected List<String> getMatchesWithClause(QueryData queryData, List<QueryNode> alternative,  String indent)
    {
      String indent2= indent + TABSTOP;
      String indent3 = indent2 + TABSTOP;
      
      StringBuilder sbRaw = new StringBuilder();
      sbRaw.append(indent).append("matchesRaw AS\n");
      sbRaw.append(indent).append("(\n");
      sbRaw.append(indent).append(getInnerQuerySqlGenerator().toSql(queryData, indent2));
      sbRaw.append("\n").append(indent).append(")");
      
      StringBuilder sbMatches = new StringBuilder();
      sbMatches.append(indent).append("matches AS\n");
      sbMatches.append(indent).append("(\n");
      
      int numOfNodes = queryData.getMaxWidth();
      for(int i=1; i <= numOfNodes; i++)
      {
        sbMatches.append(indent2)
          .append("SELECT\n");
        sbMatches.append(indent3).append("n").append(" AS n,\n");
        sbMatches.append(indent3).append(i).append(" AS nodeNr,\n");
        sbMatches.append(indent3).append("id").append(i).append(" AS id,\n");
        sbMatches.append(indent3).append("text").append(i).append(" AS \"text\",\n");
        sbMatches.append(indent3).append("min").append(i).append(" AS min,\n");
        sbMatches.append(indent3).append("max").append(i).append(" AS max,\n");
        sbMatches.append(indent3).append("corpus").append(i).append(" AS corpus\n");
        sbMatches.append(indent2).append("FROM matchesRaw\n");
        if(i < numOfNodes)
        {
          sbMatches.append(indent2).append("\n").append(indent2).append("UNION ALL\n\n");
        }
      }
      sbMatches.append("\n").append(indent).append(")");
  
      return Lists.newArrayList(sbRaw.toString(), sbMatches.toString());
    }
docs: Uses the inner SQL generator and provides an ordered and limited view on
  the matches with a match number.
  @param queryData
  @param alternative
  @param indent
  @return