@Test
  public void testLikeWithOtherIndexedField() throws Exception {
    Cache cache = CacheUtils.getCache();
    AttributesFactory attributesFactory = new AttributesFactory();
    RegionAttributes regionAttributes = attributesFactory.create();

    Region region = cache.createRegion("pos", regionAttributes);

    String base = "abc";
    for (int i = 1; i <= 10; i++) {
      Portfolio pf = new Portfolio(i);
      pf.pkid = "1";
      if ((i % 4) == 0) {
        pf.status = base;
      } else if ((i <= 2)) {
        pf.pkid = "2";
      }
      region.put(i, pf);
    }

    QueryService qs = cache.getQueryService();

    Query q = qs.newQuery(" SELECT  *  FROM " + SEPARATOR + "pos ps WHERE ps.status like '%b%'");
    SelectResults results = (SelectResults) q.execute();
    int expectedResultSize = 2;
    if (results.size() != expectedResultSize) {
      fail("Unexpected result. expected :" + expectedResultSize + " found : " + results.size());
    }

    q = qs.newQuery(
        " SELECT  *  FROM " + SEPARATOR + "pos ps WHERE ps.status like '%b%' or ps.pkid = '2' ");
    results = (SelectResults) q.execute();
    if (results.size() != (expectedResultSize * 2)) {
      fail("Unexpected result. expected :" + (expectedResultSize * 2) + " found : "
          + results.size());
    }

    // Query to be compared with indexed results.
    q = qs.newQuery(
        " SELECT  *  FROM " + SEPARATOR + "pos ps WHERE ps.status like '%b%' and ps.pkid = '1' ");
    SelectResults expectedResults = (SelectResults) q.execute();
    if (expectedResults.size() != expectedResultSize) {
      fail("Unexpected result. expected :" + expectedResultSize + " found : "
          + expectedResults.size());
    }

    // Create Index
    qs.createIndex("pkid", IndexType.FUNCTIONAL, "ps.pkid", SEPARATOR + "pos ps");

    QueryObserver old = QueryObserverHolder.setInstance(new QueryObserverAdapter() {
      private boolean indexCalled = false;

      @Override
      public void afterIndexLookup(Collection results) {
        indexCalled = true;
      }

      @Override
      public void endQuery() {
        assertTrue(indexCalled);
      }
    });

    results = (SelectResults) q.execute();
    SelectResults[][] rs = new SelectResults[][] {{results, expectedResults}};

    // rs[0][0] = results;
    // rs[0][1] = expectedResults;
    if (results.size() != expectedResultSize) {
      fail("Unexpected result. expected :" + expectedResultSize + " found : " + results.size());
    }
    // compare results.
    CacheUtils.compareResultsOfWithAndWithoutIndex(rs, this);

    q = qs.newQuery(
        " SELECT  *  FROM " + SEPARATOR + "pos ps WHERE ps.status like '%b%' or ps.pkid = '2' ");
    results = (SelectResults) q.execute();
    if (results.size() != (expectedResultSize * 2)) {
      fail("Unexpected result. expected :" + (expectedResultSize * 2) + " found : "
          + results.size());
    }

    QueryObserverHolder.setInstance(old);
  }
Query with index on other fields.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/LikePredicateJUnitTest.java