forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Visitor design pattern in QueryBuilder (opensearch-project#…
…10110) * Implementation of Visitor Design Pattern in QueryBuilder Signed-off-by: Varun Jain <[email protected]> * Adding Changelog Signed-off-by: Varun Jain <[email protected]> * Adding Changelog Signed-off-by: Varun Jain <[email protected]> * Comments addressed of michael Signed-off-by: Varun Jain <[email protected]> * Adding test case and some minor fixes in DisMaxQueryBuilder Signed-off-by: Varun Jain <[email protected]> * Modifying test cases and remove exeception Signed-off-by: Varun Jain <[email protected]> * Adding bool query builder test cases at clause level Signed-off-by: Varun Jain <[email protected]> * Fixing test case Signed-off-by: Varun Jain <[email protected]> * Additional test cases Signed-off-by: Varun Jain <[email protected]> --------- Signed-off-by: Varun Jain <[email protected]>
- Loading branch information
1 parent
7dca3ca
commit a63f8de
Showing
29 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
server/src/main/java/org/opensearch/index/query/QueryBuilderVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.query; | ||
|
||
import org.apache.lucene.search.BooleanClause; | ||
|
||
/** | ||
* QueryBuilderVisitor is an interface to define Visitor Object to be traversed in QueryBuilder tree. | ||
*/ | ||
public interface QueryBuilderVisitor { | ||
|
||
/** | ||
* Accept method is called when the visitor accepts the queryBuilder object to be traversed in the query tree. | ||
* @param qb is a queryBuilder object which is accepeted by the visitor. | ||
*/ | ||
void accept(QueryBuilder qb); | ||
|
||
/** | ||
* Fetches the child sub visitor from the main QueryBuilderVisitor Object. | ||
* @param occur defines the occurrence of the result fetched from the search query in the final search result. | ||
* @return a child queryBuilder Visitor Object. | ||
*/ | ||
QueryBuilderVisitor getChildVisitor(BooleanClause.Occur occur); | ||
|
||
/** | ||
* NoopQueryVisitor is a default implementation of QueryBuilderVisitor. | ||
* When a user does not want to implement QueryBuilderVisitor and have to just pass an empty object then this class will be used. | ||
* | ||
*/ | ||
QueryBuilderVisitor NO_OP_VISITOR = new QueryBuilderVisitor() { | ||
@Override | ||
public void accept(QueryBuilder qb) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public QueryBuilderVisitor getChildVisitor(BooleanClause.Occur occur) { | ||
return this; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.