FieldTermPrefixFinder { public List<String> getResults() { return results; } FieldTermPrefixFinder(IndexSearcher indexSearcher, JochreIndexField field, String prefix, int maxResults,
      String configId); List<String> getResults();  }
@Test public void test() throws IOException { System.setProperty("config.file", "src/test/resources/test.conf"); ConfigFactory.invalidateCaches(); String configId = "yiddish"; JochreSearchManager manager = JochreSearchManager.getInstance(configId); Analyzer analyzer = new StandardAnalyzer(); IndexWriterConfig iwc = new IndexWriterConfig(analyzer); iwc.setOpenMode(OpenMode.CREATE_OR_APPEND); IndexWriter indexWriter = new IndexWriter(manager.getIndexDir(), iwc); Document doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "apple", Store.YES)); indexWriter.addDocument(doc); doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "artichoke", Store.YES)); indexWriter.addDocument(doc); doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "artichoke", Store.YES)); indexWriter.addDocument(doc); doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "apple pie", Store.YES)); indexWriter.addDocument(doc); doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "apple pie", Store.YES)); indexWriter.addDocument(doc); doc = new Document(); doc.add(new StringField(JochreIndexField.name.name(), "banana", Store.YES)); indexWriter.addDocument(doc); indexWriter.commit(); indexWriter.close(); manager.getManager().maybeRefresh(); IndexSearcher searcher = manager.getManager().acquire(); try { FieldTermPrefixFinder finder = new FieldTermPrefixFinder(searcher, JochreIndexField.name, "a", 2, configId); List<String> results = finder.getResults(); LOG.debug("results: " + results); assertEquals(2, results.size()); assertEquals("apple pie", results.get(0)); assertEquals("artichoke", results.get(1)); finder = new FieldTermPrefixFinder(searcher, JochreIndexField.name, "ap", 2, configId); results = finder.getResults(); LOG.debug("results: " + results); assertEquals(2, results.size()); assertEquals("apple", results.get(0)); assertEquals("apple pie", results.get(1)); } finally { manager.getManager().release(searcher); } }