@Test
  public void rangeAndCompactIndexesShouldReturnTheSameResults() {
    try {
      // CacheUtils.restartCache();
      if (!isInitDone) {
        isInitDone = true;
      }
      qs.removeIndexes();

      String[] queryStr =
          new String[] {"Select status from " + SEPARATOR + "portfolio pf where status='active'",
              "Select pf.ID from " + SEPARATOR + "portfolio pf where pf.ID > 2 and pf.ID < 100",
              "Select * from " + SEPARATOR + "portfolio pf where pf.position1.secId > '2'",};

      String[] queryFields = new String[] {"status", "ID", "position1.secId",};

      for (int i = 0; i < queryStr.length; i++) {
        // Clear indexes if any.
        qs.removeIndexes();

        // initialize region.
        region.clear();
        for (int k = 0; k < 10; k++) {
          region.put("" + k, new Portfolio(k));
        }

        for (int j = 0; j < 1; j++) { // With different region size.
          // Update Region.
          for (int k = 0; k < (j * 100); k++) {
            region.put("" + k, new Portfolio(k));
          }

          // Create compact index.
          IndexManager.TEST_RANGEINDEX_ONLY = false;
          index = (IndexProtocol) qs.createIndex(queryFields[i] + "Index", IndexType.FUNCTIONAL,
              queryFields[i], SEPARATOR + "portfolio");

          // Execute Query.
          SelectResults[][] rs = new SelectResults[1][2];
          Query query = qs.newQuery(queryStr[i]);
          rs[0][0] = (SelectResults) query.execute();

          // remove compact index.
          qs.removeIndexes();

          // Create Range Index.
          IndexManager.TEST_RANGEINDEX_ONLY = true;
          index = (IndexProtocol) qs.createIndex(queryFields[i] + "rIndex", IndexType.FUNCTIONAL,
              queryFields[i], SEPARATOR + "portfolio");

          query = qs.newQuery(queryStr[i]);
          rs[0][1] = (SelectResults) query.execute();

          CacheUtils.log(
              "#### rs1 size is : " + (rs[0][0]).size() + " rs2 size is : " + (rs[0][1]).size());
          StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
          ssORrs.CompareQueryResultsWithoutAndWithIndexes(rs, 1, queryStr);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail("Test failed due to exception=" + e);
    } finally {
      IndexManager.TEST_RANGEINDEX_ONLY = false;
      isInitDone = false;
      CacheUtils.restartCache();
    }
  }
Test to compare range and compact index. They should return the same results.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/IndexMaintenanceJUnitTest.java