Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-102

[PATCH] Reader getFieldNames returns an extra blank field name

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • core/store
    • None
    • Operating System: Windows XP
      Platform: PC

    • 19058

    Description

      This class demonstrates the problem....

      import org.apache.lucene.store.*;
      import org.apache.lucene.document.*;
      import org.apache.lucene.analysis.*;
      import org.apache.lucene.analysis.standard.*;
      import org.apache.lucene.index.*;
      import org.apache.lucene.search.*;
      import org.apache.lucene.queryParser.*;

      import java.util.*;
      public class FieldsTest
      {
      public static void main (String args[]) throws Exception
      {
      Analyzer analyzer=new StandardAnalyzer();
      Directory dir= new RAMDirectory();
      IndexWriter writer = new IndexWriter(dir, analyzer, true);
      Document doc=new Document();
      doc.add (new Field("field1", "value 1", true, true, true));
      doc.add (new Field("field2", "value 2", true, true, true));
      writer.addDocument(doc);
      writer.close();
      IndexReader reader=IndexReader.open(dir);
      Collection fields=reader.getFieldNames();

      //should contain only two fields but returns 3 (last fieldname
      is blank)
      Iterator i=fields.iterator();
      while(i.hasNext())

      { System.out.println("fieldname=["+i.next()+"]"); }

      }
      }

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--FieldInfos.diff
          2 kB
          Bernhard Messer
        2. ASF.LICENSE.NOT.GRANTED--TestFieldInfos.diff
          0.8 kB
          Bernhard Messer
        3. ASF.LICENSE.NOT.GRANTED--TestIndexReader.diff
          1 kB
          Bernhard Messer
        4. ASF.LICENSE.NOT.GRANTED--TestSegmentReader.diff
          1 kB
          Bernhard Messer

        Activity

          People

            java-dev@lucene.apache.org Lucene Developers
            markharwood@totalise.co.uk Mark Harwood
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: