(self, mergetype=None, optimize=None, merge=None)
Finishes writing and saves all additions and changes to disk.

        There are four possible ways to use this method::

            # Merge small segments but leave large segments, trying to
            # balance fast commits with fast searching:
            writer.commit()

            # Merge all segments into a single segment:
            writer.commit(optimize=True)

            # Don't merge any existing segments:
            writer.commit(merge=False)

            # Use a custom merge function
            writer.commit(mergetype=my_merge_function)

        :param mergetype: a custom merge function taking a Writer object and
            segment list as arguments, and returning a new segment list. If you
            supply a ``mergetype`` function, the values of the ``optimize`` and
            ``merge`` arguments are ignored.
        :param optimize: if True, all existing segments are merged with the
            documents you've added to this writer (and the value of the
            ``merge`` argument is ignored).
        :param merge: if False, do not merge small segments.
Finishes writing and saves all additions and changes to disk.
Finishes writing and saves all additions and changes to disk .
def commit(self, mergetype=None, optimize=None, merge=None):
        """Finishes writing and saves all additions and changes to disk.

        There are four possible ways to use this method::

            # Merge small segments but leave large segments, trying to
            # balance fast commits with fast searching:
            writer.commit()

            # Merge all segments into a single segment:
            writer.commit(optimize=True)

            # Don't merge any existing segments:
            writer.commit(merge=False)

            # Use a custom merge function
            writer.commit(mergetype=my_merge_function)

        :param mergetype: a custom merge function taking a Writer object and
            segment list as arguments, and returning a new segment list. If you
            supply a ``mergetype`` function, the values of the ``optimize`` and
            ``merge`` arguments are ignored.
        :param optimize: if True, all existing segments are merged with the
            documents you've added to this writer (and the value of the
            ``merge`` argument is ignored).
        :param merge: if False, do not merge small segments.
        """

        self._check_state()
        # Merge old segments if necessary
        finalsegments = self._merge_segments(mergetype, optimize, merge)
        if self._added:
            # Flush the current segment being written and add it to the
            # list of remaining segments returned by the merge policy
            # function
            finalsegments.append(self._finalize_segment())
        else:
            # Close segment files
            self._close_segment()
        # Write TOC
        self._commit_toc(finalsegments)

        # Final cleanup
        self._finish()
def commit ( self , mergetype = None , optimize = None , merge = None ) : self . _check_state ( ) # Merge old segments if necessary finalsegments = self . _merge_segments ( mergetype , optimize , merge ) if self . _added : # Flush the current segment being written and add it to the # list of remaining segments returned by the merge policy # function finalsegments . append ( self . _finalize_segment ( ) ) else : # Close segment files self . _close_segment ( ) # Write TOC self . _commit_toc ( finalsegments ) # Final cleanup self . _finish ( )