[Feature] Implement Visitor Design Pattern in QueryBuilder #9986
Description
Is your feature request related to a problem? Please describe.
A way for developer to get the specific child query builder object from the nested QueryBuilder. For example: If a user passes a nested query, then it will be converted to a QueryBuilder object. That QueryBuilder object has some more nested querybuilders wrapped in it. There should be a way to identify and fetch the specific query builder object from the generic query builder object.
Describe the solution you'd like
Lucene has a visit method in an abstract class Query.java & QueryVisitor.java. This visit method gives power to all the classes that extend Query.java to determine the right object type (like BoolQuery, FuzzyQuery etc) from the argument passed in the visit method. Similarly, there is a need to implement the same visit method in QueryBuilder.java in OpenSearch
Additional context
If we are able build this feature then it will empower the search pipelines as then a developer will have a capability to identify the right query builder and update it as per the need.
Metadata
Assignees
Type
Projects
Status
✅ Done