Index createLexiconIndex(String[] tokens) throws Exception { IndexOnDisk index = Index.createNewIndex( ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX); LexiconBuilder lb = new LexiconBuilder(index, "lexicon", new TermCodes()); for(String tok: tokens) { lb.addTerm(tok, 1); } lb.finishedDirectIndexBuild(); lb.finishedInvertedIndexBuild(); return index; }