[
https://issues.apache.org/jira/browse/LUCENE-6667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14618951#comment-14618951
]
David Smiley commented on LUCENE-6667:
--------------------------------------
Yeah, it could be appropriate or it could be inappropriate; there is no
API/mechanism for an attribute to specify what it wants. I think it's better
to err on copying the attribute state for inserted tokens from the (first)
input token, versus dropping attribute state. It needn't be done in an
"inconsistent" way -- we could do it in a documented consistent way -- such as
take from the first token. I've had to work around this problem (also in
WordDelimiterFilter, and CommonGrams) with ugly hacks in a custom attribute --
e.g. the clear() method not actually clearing, with my custom Tokenizer
controlling the actual clearing.
As an aside, when I was doing some custom attribute stuff, I couldn't help but
think our approach to saving attribute state seemed a little heavy, since a
call to capture() creates a linked list to hold each attribute impl. Maybe the
state could be re-used with some ref-counting. I dunno.
> Custom attributes get cleared by SynonymFilter
> ----------------------------------------------
>
> Key: LUCENE-6667
> URL: https://issues.apache.org/jira/browse/LUCENE-6667
> Project: Lucene - Core
> Issue Type: Bug
> Affects Versions: 4.10.4
> Reporter: Oliver Becker
>
> I believe the Lucene API enables users to define their custom attributes (by
> extending {{AttributeImpl}}) which may be added by custom Tokenizers.
> It seems, the {{clear}} and {{copyTo}} methods must be implemented to clear
> and restore the state of this custom attribute.
> However, some filters (in our case the SynonymFilter) simply call
> {{AttributeSource.clearAttributes}} without invoking {{copyTo}}. Instead the
> filter just resets some known attributes, simply ignoring all other custom
> attributes. In the end our custom attribute value is lost.
> Is this a bug in {{SynonymFilter}} (and others) or are we using the API in
> the wrong way?
> A solution might be of course to provide empty implementations of {{clear}}
> and {{copyTo}}, but I'm not sure if this has other unwanted effects.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]