[pylucene-dev] Working with getFieldNames()

Kevin Ollivier kevino at tulane.edu
Sat Aug 26 20:11:41 PDT 2006


Hi Andi,

On Aug 26, 2006, at 5:51 PM, Andi Vajda wrote:

>
> On Sat, 26 Aug 2006, Kevin Ollivier wrote:
>
>> My environment: Python 2.4, PyLucene 2.0.0, tested on FC1 and Mac  
>> OS X 10.4.7 Intel
>>
>> I've come across a slightly odd problem, and I'm not sure what I'm  
>> doing wrong. Basically, the issue is that no matter what constant  
>> I pass for the parameter, calls to myIndexReader.getFieldNames()  
>> return an empty list. I get the same results on Linux and Mac OS  
>> X, but the test for this feature does appear to pass just fine,  
>> and on top of that, I can query fields in the index without problems.
>>
>> Here's a code snippet, where self.indexdir is the directory  
>> containing the PyLucene index:
>>
>> reader = PyLucene.IndexReader.open(self.indexdir)
>> info["NumDocs"] = reader.numDocs()
>> info["Fields"] = reader.getFieldNames 
>> (PyLucene.IndexReader.FieldOption.ALL)
>>
>> Since the test passes, I'm fairly certain I've got a problem in my  
>> code somewhere, but I was wondering if anyone may have come across  
>> this behavior before or knows what kind of mistake could cause it  
>> to happen. Aside from this issue, searching, indexing, etc. seems  
>> to work just fine (and I get a valid value for numDocs() as well).
>
> Problem found and fixed. Classes that contain static variables that  
> point at java object instances need to be initialized before their  
> static variables can be used. I had forgotten to do that for the  
> IndexReader.FieldOption class so all its constants were NULL.
>
> This is fixed in the patch attached and is also checked into svn.

Thanks, this does the trick! :-)

Regards,

Kevin

> Andi..
> <patch.txt>
> _______________________________________________
> 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