Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset Token position on reuse in predicate_token_filter #47424

Merged

Conversation

romseygeek
Copy link
Contributor

Most of the information in AnalysisPredicateScript.Token is pulled directly
from its underlying AttributeSource, but we also keep track of the token position,
and this state is held directly on the Token. This information needs to be reset when
the containing ScriptFilteringTokenFilter is re-used.

Fixes #47197

@romseygeek romseygeek requested a review from jimczi October 2, 2019 08:44
@romseygeek romseygeek self-assigned this Oct 2, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Analysis)

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments but the fix looks good to me

@@ -69,5 +69,11 @@ protected boolean accept() throws IOException {
token.updatePosition();
return script.execute(token);
}

@Override
public void reset() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ScriptedConditionTokenFilterFactory has the same issue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++, will update and add a test

@romseygeek romseygeek merged commit c2a048b into elastic:master Oct 2, 2019
romseygeek added a commit that referenced this pull request Oct 2, 2019
Most of the information in AnalysisPredicateScript.Token is pulled directly
from its underlying AttributeSource, but we also keep track of the token position,
and this state is held directly on the Token. This information needs to be reset when
the containing ScriptFilteringTokenFilter or ScriptedConditionTokenFilter is re-used.

Fixes #47197
romseygeek added a commit that referenced this pull request Oct 2, 2019
Most of the information in AnalysisPredicateScript.Token is pulled directly
from its underlying AttributeSource, but we also keep track of the token position,
and this state is held directly on the Token. This information needs to be reset when
the containing ScriptFilteringTokenFilter or ScriptedConditionTokenFilter is re-used.

Fixes #47197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

predicate_token_filter : The token.getPosition() method return wrong value
4 participants