Skip to content

Commit

Permalink
Also consider isAggregatable for non-indexed fields like ScriptField
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Oct 30, 2024
1 parent 97f0d39 commit 16dab2b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ public static boolean hasIdenticalDelegate(FieldAttribute attr, SearchStats stat
return stats.hasIdenticalDelegate(attr.name());
}

/**
* We see fields as pushable if either they are aggregatable or they are indexed.
* This covers non-indexed cases like <code>AbstractScriptFieldType</code> which hard-coded <code>isAggregatable</code> to true,
* as well as normal <code>FieldAttribute</code>'s which can only be pushed down if they are indexed.
* The reason we don't just rely entirely on <code>isAggregatable</code> is because this is often false for normal fields, and could
* also differ from node to node, and we can physically plan each node separately, allowing Lucene pushdown on the nodes that
* support it, and relying on the compute engine for the nodes that do not.
*/
public static boolean isPushableFieldAttribute(
Expression exp,
Predicate<FieldAttribute> hasIdenticalDelegate,
Predicate<FieldAttribute> isIndexed
) {
if (exp instanceof FieldAttribute fa && fa.getExactInfo().hasExact() && isIndexed.test(fa)) {
if (exp instanceof FieldAttribute fa && fa.getExactInfo().hasExact() && (fa.field().isAggregatable() || isIndexed.test(fa))) {
return (fa.dataType() != DataType.TEXT && fa.dataType() != DataType.SEMANTIC_TEXT) || hasIdenticalDelegate.test(fa);
}
return false;
Expand Down

0 comments on commit 16dab2b

Please sign in to comment.