Luiz Costa
Luiz Costa

Reputation: 1555

How can i sort the results of a lucene search between multiple indexes?

I have two lucene indexes and i need to search on the two indexes. How can i execute a search in multiple lucene indexes? How can i sort these results?

Thanks, Luiz Costa

Upvotes: 0

Views: 196

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33345

basic code.. just typed it up check out the doc for more details

IndexSearcher[] searchers = new IndexSearcher[2];
searchers[0] = new IndexSearcher(searchDirOne);
searchers[1] = new IndexSearcher(searchDirTwo);

MultiSearcher searcher = new MultiSearcher(searchers);

Query query = QueryParser.Parse("foo","bar" , new StandardAnalyzer());

Hits hits = searcher.Search(query);

MultiSearcher Documentation

Upvotes: 2

Related Questions