public Hits search(String searchPhrase, int maxNumberOfHits) throws Exception {
return search(searchPhrase, maxNumberOfHits, Version.LUCENE_4_9);
}
public Hits search(String searchPhrase, int maxNumberOfHits, Version luceneVersion) throws Exception {
Hits searchHits = new Hits();
int numberOfHits = doSearch(searchPhrase, maxNumberOfHits, luceneVersion);
searchHits.setNumberOfHits(numberOfHits);
for (ScoreDoc hit : hits) {
Document selectedDocument = indexSearcher.doc(hit.doc);
Hit aHit = new Hit();
aHit.setHitLocation(hit.doc);
aHit.setScore(hit.score);
aHit.setData(selectedDocument.get("contents"));
searchHits.getHit().add(aHit);
}
return searchHits;
}