The `search.aggs.rewrite_to_filter_by_filter` is a setting that can disable the filter by filter optimisation. It is n escape hatch setting, because normally the heuristics that control whether this optimisation is executed only trigger this optimisation if it makes sense. In the case that this setting would be set to `false` the filter by filter optimisation would forcefully never be enabled. However this only applies to `terms` and the `range` aggregations and not the `filters` (and `filter`) aggregation. However the filter by filter optimisation exist in both `terms`, `range` and `filters` aggregation.

The `search.aggs.rewrite_to_filter_by_filter` setting should be applicable to `terms`, `range` and `filters` aggregation.
server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FilterByFilterAggregator.java
* the {@link #segmentsCounted} counter because those counters are to
     * signal which operation we were allowed to perform. The filters
     * themselves will have debugging counters measuring if they could
     * perform the count from metadata or had to fall back.
     */
    private int segmentsCounted;
    /**
     * Build the aggregation. Private to force callers to go through the
     * {@link AdapterBuilder} which centralizes the logic to decide if this
     * aggregator would be faster than the native implementation.
     */
    private FilterByFilterAggregator(
        String name,
        AggregatorFactories factories,
        List<QueryToFilterAdapter> filters,
        boolean keyed,
        boolean keyedBucket,
        AggregationContext aggCtx,
        Aggregator parent,
        CardinalityUpperBound cardinality,
        Map<String, Object> metadata
    ) throws IOException {
        super(name, factories, filters, keyed, keyedBucket, null, aggCtx, parent, cardinality, metadata);
    }
    /**
     * Instead of returning a {@link LeafBucketCollector} we do the
     * collection ourselves by running the filters directly. This is safe
     * because we only use this aggregator if there isn't a {@code parent}
     * which would change how we collect buckets and because we take the
     * top level query into account when building the filters.