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 7418837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:57:26+00:00 2026-05-29T07:57:26+00:00

Playing around with Lucene. Trying to make my changes visible for other reading threads.

  • 0

Playing around with Lucene. Trying to make my changes visible for other reading threads. Without rebuilding index. For that purpose i use SearcherManager class.

Creation of manager

Directory index = new SimpleFSDirectory(new File(LUCENE_INDEX_PATH));
w = new IndexWriter(index, config);
indexReader = IndexReader.open(w, true);
manager = new SearcherManager(w, true, null, null);

Update request

w.updateDocument(t, document);
manager.maybeReopen(); // openIfChanged same behavior
w.commit();

Search request

IndexSearcher searcher = manager.acquire();
try {
    return performSearch(query, searcher, skip, limit);
} finally {
    manager.release(searcher);
    searcher = null;
}

Changes are flushed to disc, but new search request see them only after application restart (recreation of index). Looks like IndexSearcher still point to old Index.

  • 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-05-29T07:57:27+00:00Added an answer on May 29, 2026 at 7:57 am

    You don’t need to open your own IndexReader; just create the SearcherManager (from your IndexWriter) then use acquire/release from it, to get a searcher/reader.

    After adding/deleting docs with the writer, you should call maybeReopen, and then the next time you call SearcherManager.acquire the returned searcher will reflect the changes. It’s best to use a background thread (ie, not a thread doing searching) to index docs and call maybeReopen.

    You don’t need to call IndexWriter.commit to make changes visible — only call this when you require durability (ie, that all changes are safely on disk and will survive OS/JVM crash, power loss, kill -9, etc.).

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

Sidebar

Related Questions

I'm playing around with Lucene and noticed that the use of a hyphen (e.g.
While playing around with the emulator, I noticed that when trying to view a
Playing around with Timers, and trying to make them behave right when app is
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
Just playing around with the now released Silverlight 2.0. I'm trying to put a
been playing around with ResolveClientUrl(~/Confirmation.aspx) and other methods.. I am tryin go get the
I'm playing around with the <canvas> element, drawing lines and such. I've noticed that
Im playing around with the Tablesorter plug-in for jQuery and was trying to get
Just playing around with java trying to learn it etc. Here is my code
I've been playing around with Simple.Data and have run across something that I can't

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.