List of usage examples for org.apache.lucene.misc TermStats toString
@Override
public String toString()
From source file:eu.eexcess.sourceselection.redde.indexer.topterm.IndexHelper.java
License:Apache License
/** * returns the top n (to-startFrom+1) terms beginning with startFrom * /* ww w . j av a 2 s . c om*/ * @param startFrom * first term * @param to * lastTerm * @return * @throws Exception */ protected String[] getTopTerms(int startFrom, int to) throws Exception { int numTerms = to - startFrom + 1; String[] termNames = null; TermStats[] terms = HighFreqTerms.getHighFreqTerms(inIndexReader, to + 1, fieldOfInterest, new HighFreqTerms.DocFreqComparator()); termNames = new String[numTerms]; int idx = 0; for (TermStats term : terms) { String termDetails = term.toString(); int startIndex = termDetails.lastIndexOf(termVariableName) + termVariableName.length(); int endIndex = termDetails.indexOf(" ", startIndex); termNames[idx++] = termDetails.substring(startIndex, endIndex); if (idx >= numTerms) { break; } } return termNames; }