I am trying to implement a python version of the java from http://searchhub.org/2010/04/18/refresh-getting-started-with-payloads/ using pylucene. My analyzer is producing an lucene.InvalidArgsError on the init call to the DelimitedTokenFilter
The class is below, and any help is greatly appreciated. The java version compiled with the JAR files from the pylucene 3.6 build works fine.
import lucene
class PayloadAnalyzer(lucene.PythonAnalyzer):
encoder = None
def __init__(self, encoder):
lucene.PythonAnalyzer.__init__(self)
self.encoder = encoder
def tokenStream(self, fieldName, reader):
result = lucene.WhitespaceTokenizer( lucene.Version.LUCENE_CURRENT, reader )
result = lucene.LowerCaseFilter( lucene.Version.LUCENE_CURRENT, result )
result = lucene.DelimitedPayloadTokenFilter( result, '|', self.encoder )
return result