Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple Lucene indexes, with docs in same structure, for querying with sorting

I'm using Lucene Index for indexing of a couple of repositorys in a Java application. I've 3 indexes that stores documents of the same structure (fields). One contains approximately 160.000 docs, the second 30.000 and third 40.000.

There is no problem right now with the querying or sorting of result when I'm querying against one at a time. But, I want to query them all 3 and have the combined result sorted in the specified order.

Is this possible at all?

like image 719
korrekorre Avatar asked Sep 20 '25 21:09

korrekorre


1 Answers

You can use multireader

IndexReader r1= IndexReader.open(...)
IndexReader r2= IndexReader.open(...)
MultiReader multiReader = new MultiReader(r1, r2);
IndexSearcher searcher = new IndexSearcher(multiReader);

for more details you can see this example

like image 80
Tareq Salah Avatar answered Sep 22 '25 12:09

Tareq Salah