mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
fbd558382d
This change cleans up a few things in QueryParseContext and QueryShardContext that make it hard to reason about the state of these context objects and are thus error prone and should be simplified. Currently the parser that used in QueryParseContext can be set and reset any time from the outside, which makes reasoning about it hard. This change makes the parser a mandatory constructor argument removes ability to later set a different ParseFieldMatcher. If none is provided at construction time, the one set inside the parser is used. If a ParseFieldMatcher is specified at construction time, it is implicitely set on the parser that is beeing used. The ParseFieldMatcher is only kept inside the parser. Also currently the QueryShardContext historically holds an inner QueryParseContext (in the super class QueryRewriteContext), that is mainly used to hold the parser and parseFieldMatcher. For that reason, the parser can also be reset, which leads to the same problems as above. This change removes the QueryParseContext from QueryRewriteContext and removes the ability to reset or retrieve it from the QueryShardContext. Instead, `QueryRewriteContext#newParseContext(parser)` can be used to create new parse contexts with the given parser from a shard context when needed.