private void executeQuery_3(Region region, boolean checkReferentialIntegrity) throws Exception {
    // Region region = CacheUtils.createRegion("pos", Portfolio.class);

    QueryService qs;
    qs = CacheUtils.getQueryService();
    String[] queries = {
        "SELECT DISTINCT * FROM " + SEPARATOR
            + "pos pf where pf.description = 'XXXX'  and pf.status='active' and pf.createTime = 5 "};
    ObjectType resType1 = null, resType2 = null;
    SelectResults[][] sr = new SelectResults[queries.length][2];
    for (int i = 0; i < queries.length; i++) {
      Query q = null;
      try {
        q = CacheUtils.getQueryService().newQuery(queries[i]);
        QueryObserverImpl observer = new QueryObserverImpl();
        QueryObserverHolder.setInstance(observer);
        sr[i][0] = (SelectResults) q.execute();
        if (!observer.isIndexesUsed) {
          CacheUtils.log("NO INDEX USED");
        }
        // CacheUtils.log(Utils.printResult(r));
        resType1 = sr[i][0].getCollectionType().getElementType();
        resSize1 = (sr[i][0].size());
        CacheUtils.log(resType1);
        assertEquals(1, resSize1);
        set1 = (sr[i][0].asSet());
        for (final Object o : set1) {
          valPf1 = o;
          isActive1 = ((Portfolio) valPf1).isActive();
          assertTrue(isActive1);
          assertEquals("XXXX", ((Portfolio) valPf1).description);
          assertEquals(5, ((Portfolio) valPf1).getCreateTime());

        }
      } catch (Exception e) {
        e.printStackTrace();
        fail(q.getQueryString());
      }
    }

    // Create an Index on status and execute the same query again.

    qs = CacheUtils.getQueryService();
    Index index1 =
        qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "pf.status", SEPARATOR + "pos pf");
    Index index2 =
        qs.createIndex("IdIndex", IndexType.FUNCTIONAL, "pf.iD", SEPARATOR + "pos pf");
    Index index3 =
        qs.createIndex("descriptionIndex", IndexType.FUNCTIONAL, "pf.description",
            SEPARATOR + "pos pf");

    for (int i = 0; i < queries.length; i++) {
      Query q = null;
      try {
        q = CacheUtils.getQueryService().newQuery(queries[i]);
        QueryObserverImpl observer2 = new QueryObserverImpl();
        QueryObserverHolder.setInstance(observer2);
        sr[i][1] = (SelectResults) q.execute();
        if (observer2.isIndexesUsed) {
          assertEquals(1, observer2.indexesUsed.size());
        } else {
          fail("FAILED: Index NOT Used");
        }
        resType2 = sr[i][1].getCollectionType().getElementType();
        resSize2 = (sr[i][1].size());
        // strg2=resType2.getFieldNames();

        set2 = (sr[i][1].asSet());
        for (final Object o : set2) {
          valPf2 = o;
          // valPf2=stc2.get(strg2[0]);
          // valPos2=stc2.get(strg2[1]);
          isActive2 = ((Portfolio) valPf2).isActive();
          assertTrue(isActive2);
          assertEquals("XXXX", ((Portfolio) valPf2).description);
          assertEquals(5, ((Portfolio) valPf2).getCreateTime());


        }
      } catch (Exception e) {
        e.printStackTrace();
        fail(q.getQueryString());
      }
    }

    if ((resType1).equals(resType2)) {
      CacheUtils.log("Both Search Results are of the same Type i.e.--> " + resType1);
    } else {
      fail("FAILED:Search result Type is different in both the cases");
    }
    if (resSize1 == resSize2 || resSize1 != 0) {
      CacheUtils
          .log("Search Results size is Non Zero and equal in both cases i.e.  Size= " + resSize1);
    } else {
      fail("FAILED:Search result size is different in both the cases");
    }
    itert2 = set2.iterator();
    itert1 = set1.iterator();
    while (itert1.hasNext()) {
      Object pos2 = itert2.next();
      Object pos1 = itert1.next();
      Object posFromRegion = region.get(((Portfolio) pos1).getPk());
      if (!pos1.equals(pos2)) {
        fail(
            "FAILED: In both the Cases the first member of StructSet i.e. Portfolio are different. ");
      }
      if (checkReferentialIntegrity) {
        assertTrue(pos2 == pos1);
        assertTrue(pos2 == posFromRegion);
      }
      if (((Portfolio) pos2).isActive() != ((Portfolio) pos1).isActive()) {
        fail("FAILED: Status of the Portfolios found are different");
      }
      if (((Portfolio) pos2).getID() != ((Portfolio) pos1).getID()) {
        fail("FAILED: IDs of the Portfolios found are different");
      }
    }
    CacheUtils.compareResultsOfWithAndWithoutIndex(sr, this);

  }
Test index usage on PR region & Local region if the where clause contains three conditions with
two conditions indexed & the total number of from clause iterators is 1.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexWithSngleFrmAndMultCondQryJUnitTest.java