Lucene.Net.Index.IndexWriter.Commit C# (CSharp) Method

Commit() public method

Commits all changes to the index, specifying a commitUserData Map (String -> String). This just calls PrepareCommit(IDictionary{string, string}) (if you didn't already call it) and then FinishCommit.

NOTE: if this method hits an OutOfMemoryError you should immediately close the writer. See above for details.

public Commit ( string>.IDictionary commitUserData ) : void
commitUserData string>.IDictionary
return void
        public void Commit(IDictionary<string, string> commitUserData)
		{
			EnsureOpen();

            if (infoStream != null)
            {
                Message("commit: start");
            }

            lock (commitLock)
            {
                if (infoStream != null)
                {
                    Message("commit: enter lock");
                }
                if (pendingCommit == null)
                {
                    if (infoStream != null)
                    {
                        Message("commit: now prepare");
                    }
                    PrepareCommit(commitUserData);
                }
                else if (infoStream != null)
                {
                    Message("commit: already prepared");
                }

                FinishCommit();
            }
		}
		

Same methods

IndexWriter::Commit ( ) : void
IndexWriter::Commit ( long sizeInBytes ) : void

Usage Example

        public void TestGetFilterHandleNumericParseError()
        {
            NumericRangeFilterBuilder filterBuilder = new NumericRangeFilterBuilder();
            filterBuilder.SetStrictMode(false);

            String xml = "<NumericRangeFilter fieldName='AGE' type='int' lowerTerm='-1' upperTerm='NaN'/>";
            XmlDocument doc = GetDocumentFromString(xml);
            Filter filter = filterBuilder.GetFilter(doc.DocumentElement);
            Store.Directory ramDir = NewDirectory();
            IndexWriter writer = new IndexWriter(ramDir, NewIndexWriterConfig(TEST_VERSION_CURRENT, null));
            writer.Commit();
            try
            {
                AtomicReader reader = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(ramDir));
                try
                {
                    assertNull(filter.GetDocIdSet(reader.AtomicContext, reader.LiveDocs));
                }
                finally
                {
                    reader.Dispose();
                }
            }
            finally
            {
                writer.Commit();
                writer.Dispose();
                ramDir.Dispose();
            }
        }
All Usage Examples Of Lucene.Net.Index.IndexWriter::Commit
IndexWriter