@Override
      public void run2() throws CacheException {

        class MyQueryObserver extends IndexTrackingQueryObserver {

          @Override
          public void startQuery(Query query) {
            // Destroy only for first query.
            if (query.getQueryString().contains("ID>=0")) {
              Region pr = CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1);
              Region KeyRegion = null;
              for (int i = 3; i < 7; i++) {
                KeyRegion = ((PartitionedRegion) pr).getBucketRegion(i/* key */);
                if (KeyRegion != null) {
                  KeyRegion.destroyRegion();
                }
              }
            }
          }
        }

        QueryObserverHolder.setInstance(new MyQueryObserver());
      }
Test on PR on one server only using filter.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryUsingFunctionContextDUnitTest.java