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

Doron Cohen commented on LUCENE-1096:
-------------------------------------

It seems that this is a serious problem with Hits based search. An application 
deleting returned hits as in this case will actually get "holes" in the 
returned docs, every time getMoreDocs() is internally invoked. 

For instance, say all docs match, and the app deletes doc 50. Hits 0 to 99 are 
ok, they will contain docs 0 to 99. But because of the deletion, hit 100 will 
be doc 101, i.e. doc 100 was skipped.

Fixing this behavior is possible in the Hits class if only hits are deleted. 
I.e. if, while getting hit n, hits m where m<=n are deleted. But if a higher 
doc is deleted, a doc that would be seen later, after more internal calls to 
getMoreDocs(), things get more messy, and an ArrayIndexOutOfBound exception can 
be caused, as in this bug.

Note that the latter case can also happen if another thread deletes such a 
"front" hit doc. 

I think the proper exception for the latter case is 
ConcurrentModificationException, and Hits should be changed to distinguish 
between the two.

> 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: 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