Search in sources :

Example 1 with Hit

use of org.apache.camel.processor.lucene.support.Hit in project camel by apache.

the class LuceneSearcher method search.

public Hits search(String searchPhrase, int maxNumberOfHits, Version luceneVersion, boolean returnLuceneDocs) 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();
        if (returnLuceneDocs) {
            aHit.setDocument(selectedDocument);
        }
        aHit.setHitLocation(hit.doc);
        aHit.setScore(hit.score);
        aHit.setData(selectedDocument.get("contents"));
        searchHits.getHit().add(aHit);
    }
    return searchHits;
}
Also used : Hits(org.apache.camel.processor.lucene.support.Hits) Hit(org.apache.camel.processor.lucene.support.Hit) Document(org.apache.lucene.document.Document) ScoreDoc(org.apache.lucene.search.ScoreDoc)

Aggregations

Hit (org.apache.camel.processor.lucene.support.Hit)1 Hits (org.apache.camel.processor.lucene.support.Hits)1 Document (org.apache.lucene.document.Document)1 ScoreDoc (org.apache.lucene.search.ScoreDoc)1