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

Query rewrite refactoring #96280

Closed
salvatore-campagna opened this issue May 23, 2023 · 2 comments · Fixed by #96353
Closed

Query rewrite refactoring #96280

salvatore-campagna opened this issue May 23, 2023 · 2 comments · Fixed by #96353
Assignees
Labels
>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.9.0

Comments

@salvatore-campagna
Copy link
Contributor

salvatore-campagna commented May 23, 2023

Description

This refactoring is a prerequisite for #96161. The idea is to cleanup the code in order to make sure we have a better structure around the way we use QueryRewriteContext and SearchExecutionContext. Both of them are used by the rewrite logic to simplify queries and improve query execution latency and resource usage.

We would like to enable the following three scenarios:

  1. Rewrite happening on the coordinator which requires the QueryRewriteContext and a few more information but not requiring a SearchExecutionContext. This is the case for rewrite operations which happen entirely on the coordinator node and spare us from executing the query on the data node.
  2. Rewrite happening on the data node which requires the QueryRewriteContext and some information available in the SearchExecutionContext. In some scenarios an IndexSearcher is not required. Not using it saves us a few unnecessary IO operations and allows us to complete query execution before we even need to read the index.
  3. Rewrite happening on the data node which requires the QueryRewriteContext and the full SearchExecutionContext. In this scenario an IndexSearcher is required for the rewrite logic to be fully exploited.

For this reason we will refactor the SearchExecutionContext pulling up into the QueryRewriteContext a few fields/methods (like getFieldType and getIndexSettings). Moreover, we will need to revisit the implementation of doRewrite for subclasses of AbstractQueryBuilder in such a way to enable the three rewrite logic branches described above.

@salvatore-campagna salvatore-campagna added :Search/Search Search-related issues that do not fall into other categories >refactoring v8.9.0 labels May 23, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label May 23, 2023
@elasticsearchmachine
Copy link
Collaborator

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

@martijnvg
Copy link
Member

Not using it saves us a few unnecessary IO operations

Maybe also mentioning avoiding do refresh in case shard is search-idle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.9.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants