[pylucene-dev] problem creating binary fields

Andi Vajda vajda at osafoundation.org
Sat May 12 09:32:08 PDT 2007


On Sat, 12 May 2007, Andra Tori wrote:

> according to
> http://lucene.apache.org/java/2_0_0/api/index.html
>
> there is a constructor:
> Field(String name, byte[] value, Field.Store store)
>          Create a stored field with binary value.
>
> ... which is what i want since it specifies byte array as second
> argument and because this is the only constructor that accepts
> Field.Store as third parameter and no fourth.
>
> I am actually storing binary stuff in here, not unicode... How can i
> trigger that constructor?

Indeed. I misread your first question. Apologies.
Well, what you're trying to do works fine for me. I'm not getting an error.

>>> import PyLucene
>>> PyLucene.Field("show_tokens", '\xf3', PyLucene.Field.Store.YES)
<Field: u'stored/uncompressed,binary<show_tokens:[B at 15fee10>'>
>>> PyLucene.VERSION
'2.1.0-2'

If the Lucene method expects a byte[] argument, passing in a regular python 
string (type str) is correct.

Maybe you're using an older version of PyLucene where this might have been 
broken ?

Andi..


More information about the pylucene-dev mailing list