This Analyzer limits the number of tokens while indexing. It is a replacement for the maximum field length setting inside org.apache.lucene.index.IndexWriter.
상속: AnalyzerWrapper
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testLimitTokenCountAnalyzer() throws java.io.IOException
        public virtual void testLimitTokenCountAnalyzer()
        {
            foreach (bool consumeAll in new bool[] {true, false})
            {
              MockAnalyzer mock = new MockAnalyzer(random());

              // if we are consuming all tokens, we can use the checks,
              // otherwise we can't
              mock.EnableChecks = consumeAll;
              Analyzer a = new LimitTokenCountAnalyzer(mock, 2, consumeAll);

              // dont use assertAnalyzesTo here, as the end offset is not the end of the string (unless consumeAll is true, in which case its correct)!
              assertTokenStreamContents(a.tokenStream("dummy", "1  2     3  4  5"), new string[] {"1", "2"}, new int[] {0, 3}, new int[] {1, 4}, consumeAll ? 16 : null);
              assertTokenStreamContents(a.tokenStream("dummy", "1 2 3 4 5"), new string[] {"1", "2"}, new int[] {0, 2}, new int[] {1, 3}, consumeAll ? 9 : null);

              // less than the limit, ensure we behave correctly
              assertTokenStreamContents(a.tokenStream("dummy", "1  "), new string[] {"1"}, new int[] {0}, new int[] {1}, consumeAll ? 3 : null);

              // equal to limit
              assertTokenStreamContents(a.tokenStream("dummy", "1  2  "), new string[] {"1", "2"}, new int[] {0, 3}, new int[] {1, 4}, consumeAll ? 6 : null);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testLimitTokenCountAnalyzer() throws java.io.IOException
        public virtual void testLimitTokenCountAnalyzer()
        {
            foreach (bool consumeAll in new bool[] { true, false })
            {
                MockAnalyzer mock = new MockAnalyzer(random());

                // if we are consuming all tokens, we can use the checks,
                // otherwise we can't
                mock.EnableChecks = consumeAll;
                Analyzer a = new LimitTokenCountAnalyzer(mock, 2, consumeAll);

                // dont use assertAnalyzesTo here, as the end offset is not the end of the string (unless consumeAll is true, in which case its correct)!
                assertTokenStreamContents(a.tokenStream("dummy", "1  2     3  4  5"), new string[] { "1", "2" }, new int[] { 0, 3 }, new int[] { 1, 4 }, consumeAll ? 16 : null);
                assertTokenStreamContents(a.tokenStream("dummy", "1 2 3 4 5"), new string[] { "1", "2" }, new int[] { 0, 2 }, new int[] { 1, 3 }, consumeAll ? 9 : null);

                // less than the limit, ensure we behave correctly
                assertTokenStreamContents(a.tokenStream("dummy", "1  "), new string[] { "1" }, new int[] { 0 }, new int[] { 1 }, consumeAll ? 3 : null);

                // equal to limit
                assertTokenStreamContents(a.tokenStream("dummy", "1  2  "), new string[] { "1", "2" }, new int[] { 0, 3 }, new int[] { 1, 4 }, consumeAll ? 6 : null);
            }
        }
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testLimitTokenCountIndexWriter() throws java.io.IOException
        public virtual void testLimitTokenCountIndexWriter()
        {
            foreach (bool consumeAll in new bool[] {true, false})
            {
              Directory dir = newDirectory();
              int limit = TestUtil.Next(random(), 50, 101000);
              MockAnalyzer mock = new MockAnalyzer(random());

              // if we are consuming all tokens, we can use the checks,
              // otherwise we can't
              mock.EnableChecks = consumeAll;
              Analyzer a = new LimitTokenCountAnalyzer(mock, limit, consumeAll);

              IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, a));

              Document doc = new Document();
              StringBuilder b = new StringBuilder();
              for (int i = 1;i < limit;i++)
              {
            b.Append(" a");
              }
              b.Append(" x");
              b.Append(" z");
              doc.add(newTextField("field", b.ToString(), Field.Store.NO));
              writer.addDocument(doc);
              writer.close();

              IndexReader reader = DirectoryReader.open(dir);
              Term t = new Term("field", "x");
              assertEquals(1, reader.docFreq(t));
              t = new Term("field", "z");
              assertEquals(0, reader.docFreq(t));
              reader.close();
              dir.close();
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testLimitTokenCountIndexWriter() throws java.io.IOException
        public virtual void testLimitTokenCountIndexWriter()
        {
            foreach (bool consumeAll in new bool[] { true, false })
            {
                Directory    dir   = newDirectory();
                int          limit = TestUtil.Next(random(), 50, 101000);
                MockAnalyzer mock  = new MockAnalyzer(random());

                // if we are consuming all tokens, we can use the checks,
                // otherwise we can't
                mock.EnableChecks = consumeAll;
                Analyzer a = new LimitTokenCountAnalyzer(mock, limit, consumeAll);

                IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, a));

                Document      doc = new Document();
                StringBuilder b   = new StringBuilder();
                for (int i = 1; i < limit; i++)
                {
                    b.Append(" a");
                }
                b.Append(" x");
                b.Append(" z");
                doc.add(newTextField("field", b.ToString(), Field.Store.NO));
                writer.addDocument(doc);
                writer.close();

                IndexReader reader = DirectoryReader.open(dir);
                Term        t      = new Term("field", "x");
                assertEquals(1, reader.docFreq(t));
                t = new Term("field", "z");
                assertEquals(0, reader.docFreq(t));
                reader.close();
                dir.close();
            }
        }