@Test
  public void testCqResultsWithRangeIndex() throws Exception {

    final Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);

    cqDUnitTest.createServer(server);

    final int port = server.invoke(CqQueryUsingPoolDUnitTest::getCacheServerPort);
    final String host0 = NetworkUtils.getServerHostName(server.getHost());

    String poolName = "testCqResults";
    cqDUnitTest.createPool(client, poolName, host0, port);

    // Create client.
    cqDUnitTest.createClient(client, port, host0);

    // Create index.
    server.invoke(new CacheSerializableRunnable("Set RangeIndex Falg") {
      @Override
      public void run2() throws CacheException {
        IndexManager.TEST_RANGEINDEX_ONLY = true;
      }
    });

    cqDUnitTest.createFunctionalIndex(server, "IdIndex", "p.ID",
        SEPARATOR + "root" + SEPARATOR + "regionA p");
    cqDUnitTest.createFunctionalIndex(server, "statusIndex", "p.status",
        SEPARATOR + "root" + SEPARATOR + "regionA p");
    cqDUnitTest.createFunctionalIndex(server, "portfolioIdIndex", "p.position1.portfolioId",
        SEPARATOR + "root" + SEPARATOR + "regionA p");

    // Put 5 entries into the region.
    cqDUnitTest.createValues(server, "regionA", 5);

    // Test for supported queries.
    String cqQuery = "";
    for (int queryCnt = 0; queryCnt < condition.length; queryCnt++) {
      cqQuery = selStr + condition[queryCnt];
      cqDUnitTest.createCQ(client, poolName, "testCqResultsP_" + queryCnt, cqQuery);
      cqDUnitTest.executeCQ(client, "testCqResultsP_" + queryCnt, true, resultSize[queryCnt],
          expectedKeys[queryCnt], null);
    }

    // Unset the flag.
    server.invoke(new CacheSerializableRunnable("Set RangeIndex Falg") {
      @Override
      public void run2() throws CacheException {
        IndexManager.TEST_RANGEINDEX_ONLY = false;
      }
    });

    // Close.
    cqDUnitTest.closeClient(client);
    cqDUnitTest.closeServer(server);
  }
Tests CQ Result Set with Range Index.
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java