On Fri, Dec 3, 2010 at 10:15 PM, Teruhiko Kurosaka <k...@basistech.com> wrote: > Hello, > I have a Tokenizer that generates a Payload, and a TokenFilter that uses it. > These work well with Solr 1.4.0 (therefore Lucene 2.9.1?), but when > I switched to the trunk version (I rebuilt the Tokenizer and TokenFilter > using the Lucene jar from the trunk and ran it), I encountered with > this error: > > java.lang.IllegalArgumentException: This AttributeSource does not have the > attribute 'org.apache.lucene.analysis.tokenattributes.PayloadAttribute'. > > This exception comes from this line in the TokenFilter code: > > payloadAtt = (PayloadAttribute) getAttribute(PayloadAttribute.class); >
I recommend you use addAttribute instead. Its buggy to use getAttribute in this way because you cannot rely upon the fact that a previous tokenstream has added the attribute[1]. I think your code was only working before because of TokenWrapperAttributeFactory (the backwards compatibility layer in 2.9 for the old Token API) being present. [1] http://lucene.apache.org/java/2_9_0/api/core/org/apache/lucene/util/AttributeSource.html#getAttribute(java.lang.Class) --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org