lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "xzxz@mail.ru" <x...@mail.ru>
Subject Re: [jira] Commented: (LUCENENET-194) Bug in Lucene.Net.Document.Document.cs GetFieldables method
Date Tue, 15 Sep 2009 20:33:19 GMT
Ok. Here is the case:

===========code===================
  public static void TestGetFieldables()
        {
            byte[] bin = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            Directory dir = new Lucene.Net.Store.RAMDirectory();   
            IndexWriter writer = new IndexWriter(dir, new 
WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
            Document doc = new Document();
            doc.Add(new Field("bin1", bin, Field.Store.YES));
            doc.Add(new Field("bin2", bin, Field.Store.COMPRESS));
            doc.Add(new Field("junk", "junk text", Field.Store.NO, 
Field.Index.ANALYZED));

            writer.AddDocument(doc);
            writer.Close();

            IndexReader reader = IndexReader.Open(dir);
             System.Collections.Hashtable lazyFields = new 
System.Collections.Hashtable();
            lazyFields["bin1"] = "bin1";
            FieldSelector sel = new SetBasedFieldSelector(new 
System.Collections.Hashtable(), lazyFields);
            doc = reader.Document(reader.MaxDoc() - 1, sel);
            Lucene.Net.Documents.Fieldable[] fieldables = 
doc.GetFieldables("bin1") as Lucene.Net.Documents.Fieldable[];  // <- 
Exception is here
            System.Diagnostics.Debug.Assert(fieldables!=null);
            System.Diagnostics.Debug.Assert(1== fieldables.Length);
            reader.Close();
   
        }
===========/code===================

System.InvalidCastException was unhandled
  Message="At least one element in the source array could not be cast 
down to the destination array type."
  Source="mscorlib"
 ==============================

Digy (JIRA) пишет:
>     [ https://issues.apache.org/jira/browse/LUCENENET-194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12755601#action_12755601
] 
>
> Digy commented on LUCENENET-194:
> --------------------------------
>
> Hi Iliev,
>
> Everything works fine. I get no exceptions.
>
> Can you post a test case showing the bug?
>
> DIGY
>
>   
>> Bug in Lucene.Net.Document.Document.cs GetFieldables method
>> -----------------------------------------------------------
>>
>>                 Key: LUCENENET-194
>>                 URL: https://issues.apache.org/jira/browse/LUCENENET-194
>>             Project: Lucene.Net
>>          Issue Type: Bug
>>            Reporter: Iliev Andrei
>>   Original Estimate: 0h
>>  Remaining Estimate: 0h
>>
>> 		public Fieldable[] GetFieldables(System.String name)
>> 		{
>> 			/*****skip***/
>> 			return (Fieldable[]) result.ToArray(typeof(Field)); 
>> 		}
>>  SHOULD BE 
>> return (Fieldable[]) result.ToArray(typeof(Fieldable)), 
>> otherwise exception will arise.  
>>     
>
>   


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message