index.dump();
}
public List<String> complete(String partialQuery, String field) {
Iterator<AToken> it = parser.parseDocumentField(field, partialQuery);
AToken lastToken = null;
while (it.hasNext()) {
lastToken = it.next();
}
if (lastToken == null) {
return Collections.emptyList();
} else {
List<String> popularTerms = index.getMostPopular(field + ":" + lastToken.getText());
if (null == popularTerms) {
return Collections.emptyList();
} else {
int start = lastToken.getStartOffset();
String prefix = partialQuery.substring(0, start);
List<String> suggestions = new ArrayList<String>(popularTerms.size());
for (String term : popularTerms) {
term = term.substring(field.length() + 1);
suggestions.add(prefix + term);