[pylucene-dev] searching repeated and untokenized fields
Alf Eaton
lists at hubmed.org
Mon May 1 06:20:13 PDT 2006
On 01 May 2006, at 02:53, Andi Vajda wrote:
>
> On Sun, 30 Apr 2006, Alf Eaton wrote:
>
>> I have a couple of questions regarding indexing and searching a
>> document that has repeated values for the same field
>> (specifically, the authors of a document, in this case):
>>
>> Firstly, I'm adding the repeated field with this code:
>>
>> for creator in creators:
>> doc.add(Field('creator', creator, Field.Store.YES,
>> Field.Index.UN_TOKENIZED))
>>
>> but can't find a way to read those fields back out from the index.
>> If I use
>>
>> for author in hits[i]["creator"]:
>> print author
>
> I'm not sure I understand what you're trying to do in the code above.
> In PyLucene 1.9.1, the way to iterate hits is:
>
> for i, doc in hits:
> print doc['creator']
>
> If there is more than one field called 'creator' then, you might
> want to try:
> for i, doc in hits:
> for creator in doc.getFields('creator'):
> print creator
Great, that was almost it:
for i, doc in hits:
for a in doc.getFields('creator'):
author = a.stringValue()
I'll work on a proper example of my other problem.
af.
More information about the pylucene-dev
mailing list