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
*/
    @Override
    protected LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCtx, LeafBucketCollector sub) throws IOException {
        assert scoreMode().needsScores() == false;
        if (QueryToFilterAdapter.matchesNoDocs(filters())) {
            return LeafBucketCollector.NO_OP_COLLECTOR;
        }
        Bits live = aggCtx.getLeafReaderContext().reader().getLiveDocs();
        if (live != null) {
            segmentsWithDeletedDocs++;
        }
        if (false == docCountProvider.alwaysOne()) {
            segmentsWithDocCountField++;
        }
        if (subAggregators.length == 0) {
            
            /*
             * Without sub.isNoop we always end up in the `collectXXX` modes even if
             * the sub-aggregators opt out of traditional collection.
             */
            segmentsCounted++;
            collectCount(aggCtx.getLeafReaderContext(), live);
        } else {
            segmentsCollected++;
            collectSubs(aggCtx, live, sub);
        }
        return LeafBucketCollector.NO_OP_COLLECTOR;
    }
    /**
     * Gather a count of the number of documents that match each filter