Class EnableSpatialDistancePushdown
java.lang.Object
org.elasticsearch.xpack.esql.rule.Rule<FilterExec,PhysicalPlan>
org.elasticsearch.xpack.esql.rule.ParameterizedRule<FilterExec,PhysicalPlan,LocalPhysicalOptimizerContext>
org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules.ParameterizedOptimizerRule<FilterExec,LocalPhysicalOptimizerContext>
org.elasticsearch.xpack.esql.optimizer.rules.physical.local.EnableSpatialDistancePushdown
public class EnableSpatialDistancePushdown
extends PhysicalOptimizerRules.ParameterizedOptimizerRule<FilterExec,LocalPhysicalOptimizerContext>
When a spatial distance predicate can be pushed down to lucene, this is done by capturing the distance within the same function.
In principle this is like re-writing the predicate:
WHERE ST_DISTANCE(field, TO_GEOPOINT("POINT(0 0)")) <= 10000
as:
WHERE ST_INTERSECTS(field, TO_GEOSHAPE("CIRCLE(0,0,10000)")).
In addition, since the distance could be calculated in a preceding EVAL command, we also need to consider the case:
FROM index
| EVAL distance = ST_DISTANCE(field, TO_GEOPOINT("POINT(0 0)"))
| WHERE distance <= 10000
And re-write that as:
FROM index
| WHERE ST_INTERSECTS(field, TO_GEOSHAPE("CIRCLE(0,0,10000)"))
| EVAL distance = ST_DISTANCE(field, TO_GEOPOINT("POINT(0 0)"))
Note that the WHERE clause is both rewritten to an intersection and pushed down closer to the EsQueryExec,
which allows the predicate to be pushed down to Lucene in a later rule, PushFiltersToSource.-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PhysicalPlanrule(FilterExec filterExec, LocalPhysicalOptimizerContext ctx) Methods inherited from class org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules.ParameterizedOptimizerRule
applyMethods inherited from class org.elasticsearch.xpack.esql.rule.ParameterizedRule
apply
-
Constructor Details
-
EnableSpatialDistancePushdown
public EnableSpatialDistancePushdown()
-
-
Method Details
-
rule
- Specified by:
rulein classPhysicalOptimizerRules.ParameterizedOptimizerRule<FilterExec,LocalPhysicalOptimizerContext>
-