Right now the QueryRewriteContext includes two member fields allowUnmappedFields and mapUnmappedFieldAsString with their setters, which control the behaviour of the percolator through PercolatorFieldMapper and PercolateQueryBuilder. We can extract those member fields and a few methods like getFieldType and failIfFieldMappingNotFound in a subclass of QueryRewriteContext (PercolatorExecutionContext) which encapsulates the percolator-specific behaviour and create a new instance of that class by wrapping the original QueryRewriteContext (see PercolatorFieldMapper#configureContext).
We can also move the new PercolatorExecutionContext to the percolator module.
NOTE: pay attention to BWC since the percolator stores the percolator query in an index and serialisation might break.
Description
Right now the
QueryRewriteContext
includes two member fieldsallowUnmappedFields
andmapUnmappedFieldAsString
with their setters, which control the behaviour of the percolator throughPercolatorFieldMapper
andPercolateQueryBuilder
. We can extract those member fields and a few methods likegetFieldType
andfailIfFieldMappingNotFound
in a subclass ofQueryRewriteContext
(PercolatorExecutionContext
) which encapsulates the percolator-specific behaviour and create a new instance of that class by wrapping the originalQueryRewriteContext
(seePercolatorFieldMapper#configureContext
).We can also move the new
PercolatorExecutionContext
to the percolator module.NOTE: pay attention to BWC since the percolator stores the percolator query in an index and serialisation might break.
This is a followup of #96353