Lucene - Core
  1. Lucene - Core
  2. LUCENE-4203

Add IndexWriter.tryDeleteDocument, to delete by document id when possible

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0-BETA, Trunk
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Spinoff from LUCENE-4069.

      In that use case, where the app needs to first lookup a document, then
      call updateDocument, it's wasteful today because the relatively costly
      lookup (by a primary key field, eg "id") is done twice.

      But, since you already resolved the PK to docID on the first lookup,
      it would be nice to then delete by that docID and then you can call
      addDocument instead.

      So I worked out a rough start at this, by adding
      IndexWriter.tryDeleteDocument. It'd be a very expert API: it takes a
      SegmentInfo (referencing the segment that contains the docID), and as
      long as that segment hasn't yet been merged away, it will mark the
      document for deletion and return true (success). If it has been
      merged away it returns false and the app must then delete-by-term. It
      only works if the writer is in NRT mode (ie you've opened an NRT
      reader).

      In LUCENE-4069 using tryDeleteDocument gave a ~20% net speedup.

      I think tryDeleteDocument would also be useful when Solr "updates" a
      document by loading all stored fields, changing them, and calling
      updateDocument.

      1. LUCENE-4203.patch
        10 kB
        Michael McCandless
      2. LUCENE-4203.patch
        3 kB
        Michael McCandless

        Activity

        Michael McCandless created issue -
        Michael McCandless made changes -
        Field Original Value New Value
        Attachment LUCENE-4203.patch [ 12535726 ]
        Michael McCandless made changes -
        Attachment LUCENE-4203.patch [ 12538393 ]
        Michael McCandless made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 4.0 [ 12322456 ]
        Fix Version/s 5.0 [ 12321663 ]
        Resolution Fixed [ 1 ]
        Uwe Schindler made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development