[ https://issues.apache.org/jira/browse/SOLR-8460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15070065#comment-15070065 ]
Uwe Schindler commented on SOLR-8460: ------------------------------------- bq. I wrote an Attribute implementation in such a way that it didn't require some other attribute, but if it was present then it affected the functionality of the Attribute. So to know if it's present or not, I called getAttribute. That's fine. It was just general comment: If your TokenFilter needs a specific attribute, it should call addAttribute. If it only optionally uses it when available, a check with hasAttribute() is fine, too. Although I cannot guarantee that this works with all consumers (like this one!). Some producers make attributes available in a delayed way (e.g. on reset()), so calling hasAttribute or getAttribute on ctor may not reflect the real state. I think this is what happened here (because attribute init was delayed to incrementToken). I don't know why this was implemented like that - maybe because of the delayed attrbutes. I'd suggest to still crosscheck in incrementToken() if all Attributes are ready. It is not a performance issue for this handler, as it is intended for debugging only. So I would leave incrementToken() as it is. Maybe do some checks with the web interface and crazy analyzers like Kuromoji or SmartTschinese :-) > /analysis/field doesn't always handle custom attributes correctly > ----------------------------------------------------------------- > > Key: SOLR-8460 > URL: https://issues.apache.org/jira/browse/SOLR-8460 > Project: Solr > Issue Type: Bug > Components: Schema and Analysis > Reporter: David Smiley > Assignee: David Smiley > Priority: Minor > Fix For: 5.5 > > Attachments: SOLR_8460.patch > > > I've got some custom analysis Attribute implementations in my analysis chain > with some other custom analysis components. I found that Solr's Analysis > utility screen, powered by /field/analysis (FieldAnalysisRequestHandler > subclassing AnalysisRequestHandlerBase) gave me exceptions for two reasons, > both having to do with AnalysisRequestHandlerBase.ListBasedTokenStream: > * Custom implementations of standard Attributes (e.g. FlagsAttribute) would > trigger an exception. > * Calling getAttribute (instead of addAttribute) in a TokenFilter constructor > wouldn't find an attribute added by the input TokenStream. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org