  @Test
  public void testWildcard() throws Exception {

    String[] docs = new String[]{"aa ba ca da ea fa", "ba ca da ga fa ea"};
    Analyzer analyzer = getAnalyzer(
        MockTokenFilter.EMPTY_STOPSET, 50, 100);
    Directory directory = getDirectory(analyzer, docs);
    IndexReader reader = DirectoryReader.open(directory);
    IndexSearcher indexSearcher = new IndexSearcher(reader);


    IDFIndexCalc idfCalc = new IDFIndexCalc(reader);

    CooccurVisitor visitor = new CooccurVisitor(
        FIELD, 10, 10,
            new WGrammer(1, 1, "", new EmptyTokenBlackList(),false),
            idfCalc, 100, true);

    visitor.setMinTermFreq(0);
    ConcordanceArrayWindowSearcher searcher = new ConcordanceArrayWindowSearcher();
    SpanQuery q = new SpanMultiTermQueryWrapper<>(new PrefixQuery(new Term(FIELD, "b")));

    searcher.search(indexSearcher, FIELD, q, new WildcardQuery(new Term(FIELD, "g*")), analyzer, visitor,
        new IndexIdDocIdBuilder());

    List<TermIDF> results = ((CooccurVisitor) visitor).getResults();
    Map<String, Integer> truth = new HashMap<String, Integer>();
    truth.put("ca", 1);
    truth.put("da", 1);
    truth.put("ga", 1);
    truth.put("fa", 1);
    truth.put("ea", 1);

    assertEquals(truth.size(), results.size());

    for (TermIDF r : results) {
      assertEquals(r.getTerm(), truth.get(r.getTerm()).intValue(), r.getTermFreq());
    }


    reader.close();
    directory.close();
  }