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

[PATCH] Reader getFieldNames returns an extra blank field name

    Details

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

      Operating System: Windows XP
      Platform: PC

    • Bugzilla Id:
      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

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: