Lucene - Core
  1. Lucene - Core
  2. LUCENE-102

[PATCH] Reader getFieldNames returns an extra blank field name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/store
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      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()+"]"); }

      }
      }

      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

        No work has yet been logged on this issue.

          People

          • Assignee:
            Lucene Developers
            Reporter:
            Mark Harwood
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development