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

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

    for (int i = 0; i < 10; i++) {
      Portfolio p = new Portfolio(i);
      if (i % 2 == 0) {
        p.status = null;
        p.position1 = null;
        p.positions = null;
      } else {
        p.position1 = new Position("IBM", 0);
        p.status = "ACTIVE";
      }
      region.put("key-" + i, p);
    }

    String[] queries =
        {"select * from " + SEPARATOR + "pos where status.toUpperCase() like '%ACT%'",
            "select * from " + SEPARATOR + "pos where status.toUpperCase() like 'ACT%'",
            "select * from " + SEPARATOR + "pos where status.toUpperCase() like '%IVE'",
            "select * from " + SEPARATOR + "pos where status.toUpperCase() like 'ACT_VE'",
            "select * from " + SEPARATOR + "pos where status like '%CT%'",
            "select * from " + SEPARATOR + "pos where status like 'ACT%'",
            "select * from " + SEPARATOR + "pos where status like 'ACT_VE'",
            "select * from " + SEPARATOR + "pos where position1.secId like '%B%'",
            "select * from " + SEPARATOR + "pos where position1.secId like 'IB%'",
            "select * from " + SEPARATOR + "pos where position1.secId like 'I_M'",
            "select * from " + SEPARATOR
                + "pos p, p.positions.values pos where pos.secId like '%B%'",
            "select * from " + SEPARATOR
                + "pos p, p.positions.values pos where pos.secId like 'IB%'",
            "select * from " + SEPARATOR
                + "pos p, p.positions.values pos where pos.secId like 'I_M'",};
    SelectResults[][] res = new SelectResults[queries.length][2];

    QueryService qs = CacheUtils.getCache().getQueryService();
    SelectResults results = null;

    for (int i = 0; i < queries.length; i++) {
      Query q = qs.newQuery(queries[i]);
      try {
        results = (SelectResults) q.execute();
        res[i][0] = results;
      } catch (Exception e) {
        throw new RuntimeException("Query execution failed for query " + queries[i], e);
      }
      if (i < 10) {
        assertEquals("Query " + queries[i] + " should return 5 results and not " + results.size(),
            5, results.size());
      } else {
        assertEquals("Query " + queries[i] + " should return 1 results and not " + results.size(),
            1, results.size());
      }
    }

    qs.createIndex("status", "status", region.getFullPath());
    qs.createIndex("position1secId", "pos1.secId", region.getFullPath());
    qs.createIndex("secId", "pos.secId", region.getFullPath() + " pos, pos.secId");

    for (int i = 0; i < queries.length; i++) {
      Query q = qs.newQuery(queries[i]);
      try {
        results = (SelectResults) q.execute();
        res[i][1] = results;
      } catch (Exception e) {
        throw new RuntimeException("Query execution failed for query " + queries[i], e);
      }
      if (i < 10) {
        assertEquals("Query " + queries[i] + " should return 5 results and not " + results.size(),
            5, results.size());
      } else {
        assertEquals("Query " + queries[i] + " should return 1 results and not " + results.size(),
            1, results.size());
      }
    }

    CacheUtils.compareResultsOfWithAndWithoutIndex(res);
  }
Test to verify that query executes using index even when the index is being removed during the
execution
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/LikePredicateJUnitTest.java