Search in sources :

Example 1 with LuceneSearcher

use of org.apache.camel.component.lucene.LuceneSearcher in project camel by apache.

the class LuceneQueryProcessor method process.

public void process(Exchange exchange) throws Exception {
    Hits hits;
    String phrase = exchange.getIn().getHeader("QUERY", String.class);
    String returnLuceneDocs = exchange.getIn().getHeader("RETURN_LUCENE_DOCS", String.class);
    boolean isReturnLuceneDocs = (returnLuceneDocs != null && returnLuceneDocs.equalsIgnoreCase("true")) ? true : false;
    if (phrase != null) {
        searcher = new LuceneSearcher();
        searcher.open(indexDirectory, analyzer);
        hits = searcher.search(phrase, maxNumberOfHits, luceneVersion, isReturnLuceneDocs);
    } else {
        throw new IllegalArgumentException("SearchPhrase for LuceneQueryProcessor not set. Set the Header value: QUERY");
    }
    exchange.getIn().setBody(hits);
}
Also used : LuceneSearcher(org.apache.camel.component.lucene.LuceneSearcher) Hits(org.apache.camel.processor.lucene.support.Hits)

Aggregations

LuceneSearcher (org.apache.camel.component.lucene.LuceneSearcher)1 Hits (org.apache.camel.processor.lucene.support.Hits)1