[ 
https://issues.apache.org/jira/browse/LUCENE-1096?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Doron Cohen updated LUCENE-1096:
--------------------------------

    Attachment: lucene-1096.patch

Patch with tests for the two scenarios described above, and a fix for Hits.

The fix works as follows:
* Records the # deleted docs when the search starts.
* Records the total number of hits as found in the
   first call to getMoreDocs(). 
* After every additional call to getMoreDocs(), the # deleted 
   docs is checked again. 
   If it was modified, the new hits are checked to see if some 
   of the old hits are missing, due to deletions in between. 
   The start point for copying new hits into the array of hits 
    is updated accordingly. Also updated is the totalHits count.
*  Trying to fetch a hit that is not higher than the original # hits
   but is larger than the current number of hits, triggers 
   a ConcurrentModificationException, because this hit was
   deleted before we were able to retrieve it.

Note that when searching not with an IndexSearcher,
there is no access for counting deletions and so the two
arrays check is always performed - as part of getMoreDocs().
   
All tests pass.


> Deleting docs of all returned Hits during search causes 
> ArrayIndexOutOfBoundsException
> --------------------------------------------------------------------------------------
>
>                 Key: LUCENE-1096
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1096
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.1
>         Environment: WindowsXPSP1/Lenovo-T60p
>            Reporter: Tushar B
>            Assignee: Doron Cohen
>            Priority: Minor
>         Attachments: lucene-1096.patch, TestSearchDelete.java
>
>
> For background user discussion:
> http://www.nabble.com/document-deletion-problem-to14414351.html
> {code}
> Hits h = m_indexSearcher.search(q); // Returns 11475 documents 
> for(int i = 0; i < h.length(); i++) 
> { 
>   int doc = h.id(i); 
>   m_indexSearcher.getIndexReader().deleteDocument(doc);  <-- causes 
> ArrayIndexOutOfBoundsException when i = 6400
> } 
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to