Which is more efficient

classic Classic list List threaded Threaded
2 messages Options
adb
Reply | Threaded
Open this post in threaded view
|

Which is more efficient

adb
Just wondered which was more efficient under the hood

  for (int i = 0; i < size; i++)
      terms[i] = new Term("id", doc_key[i]);

This

  writer.deleteDocuments(terms);
  for (int i = 0; i < size; i++)
      writer.addDocument(doc[i]);

Or this

  for (int i = 0; i < size; i++)
      writer.updateDocument(terms[i], doc[i]);


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Which is more efficient

Michael McCandless-2
They should be very nearly the same.  Under the hood, when you call
updateDocument, IndexWriter buffers up the deleted terms, and flushes
them periodically.

Mike

On Tue, May 5, 2009 at 7:42 AM, Antony Bowesman <[hidden email]> wrote:

> Just wondered which was more efficient under the hood
>
>  for (int i = 0; i < size; i++)
>     terms[i] = new Term("id", doc_key[i]);
>
> This
>
>  writer.deleteDocuments(terms);
>  for (int i = 0; i < size; i++)
>     writer.addDocument(doc[i]);
>
> Or this
>
>  for (int i = 0; i < size; i++)
>     writer.updateDocument(terms[i], doc[i]);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]