[pylucene-dev] Document.getFields() doesn't return objects of
type Field
TJ Ninneman
tj at twopeasinabucket.com
Wed May 21 14:47:13 PDT 2008
Wow, I really apologize for posting here before reading through the
docs....it was there, plain as day.
Thanks again,
TJ
On May 21, 2008, at 4:45 PM, Andi Vajda wrote:
>
> On Wed, 21 May 2008, TJ Ninneman wrote:
>
>> For some reason it seems the Document.getFields() method returns a
>> List of fields that are not of the type Field. As you'll see
>> below, they don't have the same type or attributes:
>>
>>>>> doc = lucene.Document()
>>>>> field = lucene.Field("myfield", lucene.StringReader("mystring"))
>>
>>>>> field
>> <Field: indexed,tokenized<myfield:java.io.StringReader at d59d3c>>
>>>>> field.name()
>> u'myfield'
>>
>>>>> doc.add(field)
>>>>> fields = doc.getFields()
>>
>>>>> fields.get(0)
>> <Object: indexed,tokenized<myfield:java.io.StringReader at d59d3c>>
>
> Java declares a List to contain instances of Object. Until Lucene
> makes use of Java 1.5 feature, such as generics, and declares this
> list a List<Field>, there is nothing JCC can do, automatically, to
> determine what the intended wrapper class should be.
>
> For this, there is a cast_() Class method defined on all classes
> exported by JCC to cast anything permitted to an instance of the
> class it is called from. See line 119 of [1]. See sample code for
> many examples of use.
>
> Andi..
>
> [1] http://svn.osafoundation.org/pylucene/trunk/jcc/README
> _______________________________________________
> pylucene-dev mailing list
> pylucene-dev at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
More information about the pylucene-dev
mailing list