private void likeWithNewLine(boolean useIndex) throws Exception {
    // setup
    Cache cache = CacheUtils.getCache();
    AttributesFactory attributesFactory = new AttributesFactory();
    RegionAttributes regionAttributes = attributesFactory.create();
    Region region = cache.createRegion("pos", regionAttributes);

    region.put("abc", "abc\ndef");
    region.put("opq", "\nopq");
    region.put("mns", "opq\n");
    QueryService qs = cache.getQueryService();
    if (useIndex) {
      qs.createIndex("p", IndexType.FUNCTIONAL, "p", SEPARATOR + "pos p");
    }
    Query query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%bc%'");
    SelectResults sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%bc\n%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%bcde%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 0); // no results as newline is required
                                // whitespace
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%bc\nde%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%de%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%\nde%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%bc%de%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%zyx%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 0);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%\n%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 3); // find newline anywhere in string
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '\n%'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
    query = qs.newQuery("select * from " + SEPARATOR + "pos a where a like '%\n'");
    sr = (SelectResults) query.execute();
    assertEquals(sr.size(), 1);
  }
Query with index on other fields.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/LikePredicateJUnitTest.java