Note that there are some explanatory texts on larger screens.

plurals
  1. POApache lucene 4.3.1 - Index reader is not reach to the last indexed document
    primarykey
    data
    text
    <p>In My App I have documents represents my data for each category, my application perform an automatic index to new and the modified documents.</p> <p>if i performed index for all documents in one category, its work fine and retrieve a correct results, but the problem is, if i modified or create new document its will not retrieve it, if its matched my search query.</p> <p>usually keeps return all docs except the last modified one.</p> <p>any help please ?</p> <p>I have this IndexWriter config :</p> <pre><code>private IndexWriter getIndexWriter() throws IOException { Directory directory = FSDirectory.open(new File(filepath)); IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, IndexFactory.ANALYZER); config.setRAMBufferSizeMB(350); TieredMergePolicy tmp = new TieredMergePolicy(); tmp.setUseCompoundFile(false); config.setMergePolicy(tmp); ConcurrentMergeScheduler scheduler = (ConcurrentMergeScheduler) config.getMergeScheduler(); scheduler.setMaxThreadCount(2); scheduler.setMaxMergeCount(20); IndexWriter writer = new IndexWriter(directory, config); writer.forceMerge(1); return writer; </code></pre> <p>My Collector :</p> <pre><code>public void collect(int docNum) throws IOException { try { if ((getCount() == getMaxSearchLimit() + 1) &amp;&amp; getMaxSearchResults() != null) { setCounterExceededLimit(true); return; } addDocKey();// method to add and render the matching docs by customize way } catch(IOException exp) { if (!getErrors().toArrayList(getApplication().getLocale()).contains(exp.getMessage())) { getErrors().addError(exp.getMessage()); } } catch (BusinessException bEx) { if (!getErrors().containsError(bEx.getErrorNumber())) { getErrors().addError(bEx); } } catch (CounterExceededLimitException counterEx) { return; } } @Override public boolean acceptsDocsOutOfOrder() { // TODO Auto-generated method stub return true; } @Override public void setNextReader(AtomicReaderContext context) throws IOException { // TODO Auto-generated method stub } @Override public void setScorer(Scorer scorer) throws IOException { // TODO Auto-generated method stub } </code></pre> <p>acually i have this busniess logic to save my doc, then i asked if the doc saved successfully to add it to the index process.</p> <pre><code>public boolean saveDocument(CategoryDocument doc) { boolean saved = false; // code to save my doc if(saved) { //add this document to the index process IndexManager.getInstance().addToIndex(this); } </code></pre> <p>}</p> <p>then my index manager create a new thread to handle indexing this doc. here is my process to index my data document :</p> <pre><code>private void processDocument(IndexDocument indexDoc, DocKey docKey, boolean addToIndex) throws SearchException, BusinessException { CategorySetting catSetting = docKey.getCategorySetting(); Integer catID = catSetting.getID(); IndexManager manager = IndexManager.getInstance(); IndexWriter writer = null; try { //Delete the lock file in case previous index operation failed to delete it File lockFile = new File(filepath, IndexWriter.WRITE_LOCK_NAME); if (lockFile != null &amp;&amp; lockFile.exists()) { lockFile.delete(); } if(!manager.isGlobalIndexingProcess(catID)) { writer = getIndexWriter(); } else { writer = manager.getGlobalIndexWriter(catID); } writer.forceMerge(1); removeDocument(docKey, writer); if (addToIndex) { writer.addDocument(indexDoc.getLuceneIndexDoc()); } } catch(IOException exp) { throw new SearchException(exp.getMessage(), true); } finally { if(!manager.isGlobalIndexingProcess(catID)) { if (writer != null) { try { writer.close(true); } catch(IOException ex) { throw new SearchException(ex); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload