}
public String[] suggest(String queryString, IndexReader idxReader, String field){
List<String> results = new ArrayList<String>(maxSuggestionSize);
if(queryString != null && queryString.length() >= minQueryStringLength){
Term term = new Term("t", queryString);
PrefixQuery prefixQuery = new PrefixQuery(term);
IndexReader indexReader = null;
IndexSearcher indexSearch = null;
try{
indexReader = searchSuggestIndexer.openSuggestIndexReader();
indexSearch = new IndexSearcher(indexReader);
Hits hits = indexSearch.search(prefixQuery);
int maxNumCandidate = maxSuggestionSize;
if(idxReader != null && field != null){
maxNumCandidate = maxSuggestionSize * 10;
}
PriorityQueue<SuggestWord> suggestQueue = new PriorityQueue<SuggestWord>(maxNumCandidate);
for(int i = 0; i < hits.length() && i < maxNumCandidate; i++){
String sugWord = hits.doc(i).get("t");
// check if the 'sugWord' matches at least one doc in the
// source index database (idxReader)
if(idxReader != null && field != null){
int freq = idxReader.docFreq(new Term(field,sugWord));
if(freq > 0){
suggestQueue.add(new SuggestWord(sugWord,freq));
}
}else{
suggestQueue.add(new SuggestWord(sugWord,0));