-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix IndexSearcherWrapper visibility #39071
Conversation
This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin. This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed. Closes elastic#30758
Pinging @elastic/es-search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimczi Thanks Jim, makes sense.
protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) throws IOException { | ||
// we cannot use the asserting searcher because the weight is created by the ContextIndexSearcher | ||
wrappedSearcher.search(leaves, weight, collector); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand we don't want to call AssertingIndexSearcher::search
as it will fail, as it expects AssertingWeight
.
But I am wondering if we are losing anything by not calling search
method of AssertingIndexSearcher
? Or it doesn't matter, cause even before this PR when AssertingIndexSearcher
is wrapped in ContextIndexSearcher
we were not calling AssertingIndexSearcher::search
anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky tricky, I can't think of a way to work around this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep me neither, it's not a regression though since the current code is also not using AssertingIndexSearcher::search. I think we need a better integration of the ContextIndexSearcher
if you're willing to keep the ability to extend IndexSearcher
in a plugin but this is probably out of the scope of this pr that I consider as a workaround (hack ;)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mayya has a good point, but I can't think of a way to address it. Other than that the change looks good to me.
protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) throws IOException { | ||
// we cannot use the asserting searcher because the weight is created by the ContextIndexSearcher | ||
wrappedSearcher.search(leaves, weight, collector); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky tricky, I can't think of a way to work around this?
* Fix IndexSearcherWrapper visibility This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin. This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed. Closes elastic#30758
This commit ensures that we delegate the creation of the query weight to the AssertingIndexSearcher when possible (if the query does not need to access distributed frequency statistics). This fixes test failures that uses a ContextIndexSearcher wrapped with an AssertingIndexSearcher. Relates elastic#39071
|
…te-size-hard-failure * elastic/master: use shell with JAVA_HOME for starting archive (elastic#40118) Remove Migration Upgrade and Assistance APIs (elastic#40075) Revert "Fix IndexSearcherWrapper visibility (elastic#39071)" Remove transport name from tcp channel (elastic#40074) Document the limitation around field aliases and percolator. (elastic#40073) SQL: Refactor Literals serialization method (elastic#40058)
This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin. This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed. Closes elastic#30758
This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin. This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed. Closes #30758
This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin.
This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed.
Closes #30758