@Test
  public void testIndexCreationWithoutLoadingData() throws Exception {
    QueryService qs;
    qs = CacheUtils.getQueryService();

    Index i1 = ((DefaultQueryService) qs).createIndex("statusIndex", IndexType.FUNCTIONAL, "status",
        SEPARATOR + "portfolios", null, false);
    Index i2 = ((DefaultQueryService) qs).createIndex("secIndex", IndexType.FUNCTIONAL, "pos.secId",
        SEPARATOR + "portfolios p, p.positions.values pos", null, false);
    Index i3 = ((DefaultQueryService) qs).createIndex("statusHashIndex", IndexType.HASH, "status",
        SEPARATOR + "portfolios", null, false);

    assertEquals("Index should have been empty ", 0, i1.getStatistics().getNumberOfKeys());
    assertEquals("Index should have been empty ", 0, i1.getStatistics().getNumberOfValues());
    assertEquals("Index should have been empty ", 0, i2.getStatistics().getNumberOfKeys());
    assertEquals("Index should have been empty ", 0, i2.getStatistics().getNumberOfValues());
    assertEquals("Index should have been empty ", 0, i3.getStatistics().getNumberOfKeys());
    assertEquals("Index should have been empty ", 0, i3.getStatistics().getNumberOfValues());

    qs.removeIndexes();

    i1 = ((DefaultQueryService) qs).createIndex("statusIndex", IndexType.FUNCTIONAL, "status",
        SEPARATOR + "portfolios", null, true);
    i2 = ((DefaultQueryService) qs).createIndex("secIndex", IndexType.FUNCTIONAL, "pos.secId",
        SEPARATOR + "portfolios p, p.positions.values pos", null, true);
    i3 = ((DefaultQueryService) qs).createIndex("statusHashIndex", IndexType.HASH, "status",
        SEPARATOR + "portfolios", null, true);

    assertEquals("Index should not have been empty ", 2, i1.getStatistics().getNumberOfKeys());
    assertEquals("Index should not have been empty ", 4, i1.getStatistics().getNumberOfValues());
    assertEquals("Index should not have been empty ", 8, i2.getStatistics().getNumberOfKeys());
    assertEquals("Index should not have been empty ", 8, i2.getStatistics().getNumberOfValues());
    assertEquals("Index should not have been empty ", 0, i3.getStatistics().getNumberOfKeys()); // hash
                                                                                                // index
                                                                                                // does
                                                                                                // not
                                                                                                // have
                                                                                                // keys
    assertEquals("Index should not have been empty ", 4, i3.getStatistics().getNumberOfValues());
  }
Test for bug 46872, make sure we recover the index correctly if the cache.xml changes for a
persistent region.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexCreationJUnitTest.java