forked from opensearch-project/opensearch-net
-
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.
Signed-off-by: Kostas <[email protected]>
- Loading branch information
1 parent
85451de
commit ab7fd4f
Showing
2 changed files
with
63 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
31 changes: 31 additions & 0 deletions
31
src/OpenSearch.Client/QueryDsl/Visitor/QueryNodeModifierVisitor.cs
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,31 @@ | ||
using System; | ||
|
||
namespace OpenSearch.Client.QueryDsl.Visitor | ||
{ | ||
public class QueryNodeModifierVisitor : QueryVisitor | ||
{ | ||
private readonly Action<IQuery, Context> action; | ||
private Context context; | ||
|
||
public struct Context | ||
{ | ||
public int Depth { get; internal set; } | ||
public VisitorScope Scope { get; internal set; } | ||
} | ||
|
||
public QueryNodeModifierVisitor(Action<IQuery, Context> action) | ||
{ | ||
this.action = action; | ||
context = new Context(); | ||
} | ||
|
||
public override void Visit(IQuery query) | ||
{ | ||
context.Depth = Depth; | ||
context.Scope = Scope; | ||
|
||
action(query, context); | ||
base.Visit(query); | ||
} | ||
} | ||
} |