Lucene.Net.Index.IndexWriterConfig.SetInfoStream C# (CSharp) Method

SetInfoStream() public method

Information about merges, deletes and a message when maxFieldLength is reached will be printed to this. Must not be null, but InfoStream#NO_OUTPUT may be used to supress output.
public SetInfoStream ( Lucene.Net.Util.InfoStream infoStream ) : IndexWriterConfig
infoStream Lucene.Net.Util.InfoStream
return IndexWriterConfig
        public IndexWriterConfig SetInfoStream(InfoStream infoStream)
        {
            if (infoStream == null)
            {
                throw new System.ArgumentException("Cannot set InfoStream implementation to null. " + "To disable logging use InfoStream.NO_OUTPUT");
            }
            this.infoStream = infoStream;
            return this;
        }

Same methods

IndexWriterConfig::SetInfoStream ( TextWriter printStream ) : IndexWriterConfig

Usage Example

Ejemplo n.º 1
0
        public virtual void TestInfoStreamGetsFieldName()
        {
            Directory             dir = NewDirectory();
            IndexWriter           writer;
            IndexWriterConfig     c                     = new IndexWriterConfig(TEST_VERSION_CURRENT, new ThrowingAnalyzer());
            ByteArrayOutputStream infoBytes             = new ByteArrayOutputStream();
            StreamWriter          infoPrintStream       = new StreamWriter(infoBytes, Encoding.UTF8);
            TextWriterInfoStream  printStreamInfoStream = new TextWriterInfoStream(infoPrintStream);

            c.SetInfoStream(printStreamInfoStream);
            writer = new IndexWriter(dir, c);
            Document doc = new Document();

            doc.Add(NewField("distinctiveFieldName", "aaa ", storedTextType));
            try
            {
                writer.AddDocument(doc);
                Assert.Fail("Failed to fail.");
            }
            catch (BadNews)
            {
                infoPrintStream.Flush();
                string infoStream = Encoding.UTF8.GetString(infoBytes.ToArray());
                Assert.IsTrue(infoStream.Contains("distinctiveFieldName"));
            }

            writer.Dispose();
            dir.Dispose();
        }
All Usage Examples Of Lucene.Net.Index.IndexWriterConfig::SetInfoStream