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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:26:27+00:00 2026-05-19T10:26:27+00:00

Sorry for the simple question, but there doesn’t seem to be any obvious way.

  • 0

Sorry for the simple question, but there doesn’t seem to be any obvious way. According to the documentation, it is recommended to keep a single instance of IndexWriter in memory that can be used again and again for updates, as opposed to opening and closing one for each change (which is much more costly).

However, the documentation also states that the IndexWriter should be closed if an exception occurs (e.g. OutOfMemoryException).

Therefore, I need some way to check if my instance of IndexWriter is valid or not, assuming it could be closed by some other operation.

I realize I will get an exception if I try to use it when it’s closed, but rather than fail, I would like to check to see if I need to create a new IndexWriter before I need it so no failure occurs.

It seems to me a simple IsOpen property/method would be such an obvious addition.

Thoughts:

I suppose that if I could ensure that my class is the only thing capable of closing the IndexWriter, I could simply set it to null when it was closed and just check to make sure it’s not null whenever I go to use it, however this would not handle cases where the IndexWriter closes itself (if such a case is possible now or in the future).

Another thought is that I could wrap an attempt to use it in a try/catch block and use the exception to indicate that it needs to be reopened, but this doesn’t seem very efficient/elegant. What method would I use to test the validity of the IndexWriter?

  • 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-19T10:26:28+00:00Added an answer on May 19, 2026 at 10:26 am

    If you get an out of memory exception (or any kind of exception, really), that’s potentially a big problem. The changes you were trying to write probably won’t get written, and your index may even be corrupt, depending on when/how the exception occurred.

    So an IndexWriter being in a faulted state is an exceptional circumstance, and I would say it certainly warrants using exceptions, i.e. try/catch.

    (I don’t think your catch would be “reopen the writer.” Depending on the exception, you might need to reindex stuff, possibly from scratch. Certainly you shouldn’t expect to get exceptions in your writer as a regular occurrence.)

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

Sidebar

Related Questions

Sorry for the simple question but I feel like there's a smarter way to
Sorry if this is a dead simple question but I'm confused from the documentation
Note: I'm sorry if this is an extremely simple question but I'm somewhat obsessive
Sorry if this is a dense question, but I'm looking to see if there
Sorry, simple question but it is something that is always confused me when speaking
Sorry for a very simple question, but I'm just beginning with HTML & CSS
Sorry if this is too simple, but thanks in advance for helping. This is
Sorry to put a post up about something so simple, but I don't see
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
Sorry for the ambiguous title but I'm doing the following to write a simple

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.