Lucene only allows for one open transaction at a time per index (IndexWriter).

So if you have multiple threads, and each of them is making changes,
all those changes will fall under one transaction, controlled by the
single writer the threads are sharing.

If you really want separate transactions, I think you have to do this
against separate indices, and then merge the indices together
(IndexWriter.addIndexes) into a single one, or, leave them separate
and use multiple searchers over them.

Mike

Sergey Kabashnyuk <[EMAIL PROTECTED]> wrote:
> Thanks Mike for you replay.
>
>  What about multithreading? If in one transaction can make both
>  adding and deleting documents and in the same time can be more then
>  one open transaction. Should each thread use it personal Index and
>  after commiting transaction somehow it merges or all threads must use one
>  index?
>
>  Sergey Kabashnyuk.
>
>
>  > You should open the IndexWriter with autoCommit=false, then make
>  > changes.  During this time, any reader that opens the index will not
>  > see any changes you are making.
>  >
>  > Then, you can call close() to commit the changes to the index, or
>  > abort() to rollback the index to the starting state (when the writer
>  > was opened).
>  >
>  > Note that in 3.0, IndexWriter will be hardwired to autoCommit=false
>  > (in trunk those ctors taking autoCommit are deprecated) and a new
>  > commit() method can be used to periodically commit without closing if
>  > you want to.
>  >
>  > Mike
>  >
>  > Sergey Kabashnyuk <[EMAIL PROTECTED]> wrote:
>  >> Hi.
>  >>  I have a question about transactions  in Lucene.
>  >>
>  >>  Lets say I have 1000 Documents and want to add all of them or none of
>  >>  them(if something happen) to the index.
>  >>
>  >>  What the best strategy to do it in multithreaded environment?
>  >>
>  >>  Sergey Kabashnyuk.
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>
>
>
>
>  --
>  Отправлено M2, революционной почтовой программой Opera:
>  http://www.opera.com/mail/
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to