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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:19:11+00:00 2026-05-31T05:19:11+00:00

My users are submitting document to my application which updates the index and other

  • 0

My users are submitting document to my application which updates the index and other users can query that index. Unlike crawlers, the indexing is intermittent — only index when a user submits a document. I expect more Index Searches than Index write operations. ( I am not using Solr because that is an overkill for my need) and no deletes or updates of indexed documents.

This is my code for adding document to Index and reading from the Index. How can I optimize it further ?

public void addDocument(Document doc) throws CorruptIndexException, LockObtainFailedException, IOException{

    IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUCENE_35)).setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE).setRAMBufferSizeMB(256.0);
    TieredMergePolicy tmp = new TieredMergePolicy();
    tmp.setUseCompoundFile(false);
    tmp.setMaxMergedSegmentMB(1000000.0);
    //tmp.setReclaimDeletesWeight(3.0);
    //tmp.setMaxMergedSegmentMB(7000.0);
    iwc.setMergePolicy(tmp);
    // Make sure merges run @ higher prio than indexing:
    final ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) iwc.getMergeScheduler();
    cms.setMergeThreadPriority(Thread.currentThread().getPriority() + 2);
    cms.setMaxThreadCount(1);
    cms.setMaxMergeCount(4);



    IndexWriter iw = new IndexWriter(directory, iwc);
    iw.addDocument(doc);
    iw.close();
}

When a search request comes in, I create a new IndexSearcher as follows

public IndexSearcher getIndexSearcher() throws CorruptIndexException, IOException {

        IndexSearcher is= new IndexSearcher(IndexReader.open(directory, false));
        return is;
    }

// I then use the searcher for actual queries not shown here

  • 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-31T05:19:11+00:00Added an answer on May 31, 2026 at 5:19 am

    Keep IndexWriters and IndexReader around. Don’t open a new writer and close it just to add a single document. Don’t open a new reader just to respond to one query, use SearcherManager or NRTManager instead.

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

Sidebar

Related Questions

I have a rails app which requires users to verify that they own a
In one part of my app users can copy a Word or rtf document
Yesterday one of our remote users was submitting a changelist through P4V. The submit
Here is a snippet from a Sinatra app where users will be submitting urls.
I'd like to allow users on my site to preview their posts before submitting
I have a form that I'm submitting with AJAX. A user fills out the
Users are pasting text from Lotus Notes into my VBA application. This is then
Users on my site can add nodes of a custom type (let's call it
Users on my site can post news items. But right now, it's all honor
I am currently writing an application which I plan to sell as SaaS. Without

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.