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
private FilterByFilterAggregator agg;
                @Override
                public FilterByFilterAggregator apply(AggregatorFactories subAggregators) throws IOException {
                    agg = new FilterByFilterAggregator(
                        name,
                        subAggregators,
                        filters,
                        keyed,
                        keyedBucket,
                        aggCtx,
                        parent,
                        cardinality,
                        metadata
                    );
                    return agg;
                }
            }
            AdapterBuild adapterBuild = new AdapterBuild();
            T result = adapt(adapterBuild);
            if (adapterBuild.agg.scoreMode().needsScores()) {
                /*
                 * Filter by filter won't produce the correct results if the
                 * sub-aggregators need scores because we're not careful with how
                 * we merge filters. Right now we have to build the whole
                 * aggregation in order to know if it'll need scores or not.
                 * This means we'll build the *sub-aggs* too. Oh well.
                 */