Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:59:59+00:00 2026-05-31T23:59:59+00:00

I am about to write a near-realtime search application with distributed indexes. Now I

  • 0

I am about to write a near-realtime search application with distributed indexes. Now I wonder what is the correct approch to implement search over multiple indexes:

I have read about the MultiSearcher, so one approch would be:

IndexSearcher[] indexSearchers = new IndexSearcher[indexCount];

for (int i = 0; i < indexCount; i++) {
    File directory = new File(indexdir, String.valueOf(i));
    IndexWriter indexWriter = new IndexWriter(FSDirectory.open(directory), analyzer, IndexWriter.MaxFieldLength.LIMITED);

    IndexReader indexReader = indexWriter.getReader();
    indexSearchers[i] = new IndexSearcher(indexReader);
}

MultiSearcher searcher = new MultiSearcher(indexSearchers);

But as I see this is also possible:

IndexReader[] indexReader = new IndexReader[indexCount];

for (int i = 0; i < indexCount; i++) {
    File directory = new File(indexdir, String.valueOf(i));
    IndexWriter indexWriter = new IndexWriter(FSDirectory.open(directory), analyzer, IndexWriter.MaxFieldLength.LIMITED);

    indexReader[i] = indexWriter.getReader();        
}

IndexSearcher searcher = new IndexSearcher(new MultiReader(indexReader));

Is there any significant difference between these two approches? The second one would be easyer to handle if the reader is out of data, because I could just call MultiReader.reopen() instead of iterating over all IndexReaders, reopening them and than creating new IndexSearchers…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:00:01+00:00Added an answer on June 1, 2026 at 12:00 am

    You should use the second option: http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/api/all/org/apache/lucene/search/MultiSearcher.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just about to write my first application in a duck typed language (Groovy).
I'm about to write a Scala command-line application that relies on a MySQL database.
say I'm about to write an application with a thin GUI layer, a really
I am about to write unit tests for a new web application. My preferred
I'm about to write a small and lightweight dependency management tool for Android projects.
I am about to write a tender. The solution might be a PHP based
When I'm about to write a short algorithm, I first check in the base
I'm about to write a Wrapper for a COM interop IStream so that code
I'm about to write server side aplication(most probably it would be PHP but JAVA
I'm learning jQuery and am about to write some pages using intensively that library.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.