@Test
  public void testIndexUsageWithOrderBy3() throws Exception {
    QueryService qs = CacheUtils.getQueryService();
    LocalRegion testRgn = (LocalRegion) CacheUtils.createRegion("testRgn", null);

    int numObjects = 30;
    // Add some test data now
    // Add 5 main objects. 1 will contain key1, 2 will contain key1 & key2
    // and so on
    for (int i = 0; i < numObjects; i++) {
      Portfolio p = new Portfolio(i);
      p.pkid = ("" + (numObjects - i));
      testRgn.put("" + i, p);
    }

    qs = CacheUtils.getQueryService();
    String[] queries =
        {"SELECT DISTINCT * FROM " + SEPARATOR
            + "testRgn p  WHERE p.ID <= 10 order by ID asc limit 1",
            "SELECT DISTINCT * FROM " + SEPARATOR
                + "testRgn p  WHERE p.ID <= 10 order by p.ID desc limit 1",};

    Object[][] r = new Object[queries.length][2];

    Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "p.ID", SEPARATOR + "testRgn p");

    // Execute Queries with Indexes
    for (int i = 0; i < queries.length; i++) {
      Query q = CacheUtils.getQueryService().newQuery(queries[i]);
      CacheUtils.getLogger().info("Executing query: " + queries[i]);
      QueryObserverImpl observer = new QueryObserverImpl();
      QueryObserverHolder.setInstance(observer);
      SelectResults sr = (SelectResults) q.execute();
      List results = sr.asList();
      for (int rows = 0; rows < results.size(); rows++) {
        Portfolio p = (Portfolio) results.get(0);
        CacheUtils.getLogger().info("index p: " + p);
        if (i == 0) {
          assertEquals(p.getID(), 0);

        } else if (i == 1) {
          assertEquals(p.getID(), 10);

        }
      }
      r[i][1] = sr;
      CacheUtils.log("Executing query: " + queries[i] + " with index created");
      if (!observer.isIndexesUsed) {
        fail("Index is NOT uesd");
      }
      Iterator itr = observer.indexesUsed.iterator();
      assertTrue(itr.hasNext());
      String temp = itr.next().toString();
      assertEquals(temp, "Index1");
    }
  }
Test to check if Region short cut method is used for querying, the Primary key index
utilization occurs or not
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/IndexUseJUnitTest.java