DirectoryReader r = w.getReader();
w.close();
AtomicReader sub = getOnlySegmentReader(r);
Terms terms = sub.fields().terms("field");
Automaton automaton = new RegExp(".*", RegExp.NONE).toAutomaton();
CompiledAutomaton ca = new CompiledAutomaton(automaton, false, false);
TermsEnum te = terms.intersect(ca, null);
assertEquals("aaa", te.next().utf8ToString());
assertEquals(0, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertEquals("bbb", te.next().utf8ToString());
assertEquals(1, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());