@Test
  public void testNullAndUndefinedValuesForMapKeyInCompactRangeIndex() throws Exception {
    index = utils.createIndex("indexName", "positions['SUN']", SEPARATOR + "exampleRegion");
    Region<Object, Object> region = utils.getCache().getRegion("exampleRegion");

    // create objects
    Portfolio p1 = new Portfolio(1);
    p1.positions = new HashMap<>();
    p1.positions.put("SUN", "yes");
    region.put("KEY-" + 1, p1);

    // Equivalent to having a null value for positions['SUN'] when querying
    Portfolio p2 = new Portfolio(2);
    p2.positions = new HashMap<>();
    p2.positions.put("ERIC", 2);
    region.put("KEY-" + 2, p2);

    // Undefined value for positions['SUN'] when querying
    Portfolio p3 = new Portfolio(3);
    p3.positions = null;
    region.put("KEY-" + 3, p3);

    // null value for positions['SUN']
    Portfolio p4 = new Portfolio(4);
    p4.positions = new HashMap<>();
    p4.positions.put("SUN", null);
    region.put("KEY-" + 4, p4);

    // execute query for null value and check result size
    QueryService qs = utils.getCache().getQueryService();
    SelectResults<Object> results = UncheckedUtils.uncheckedCast(qs
        .newQuery(
            "Select * from " + SEPARATOR + "exampleRegion r where r.positions['SUN'] = null")
        .execute());
    assertThat(results.size()).isEqualTo(2);
    assertThat(results.contains(p2)).isTrue();
    assertThat(results.contains(p4)).isTrue();

    // execute query for not null value and check result size
    results = UncheckedUtils.uncheckedCast(qs
        .newQuery(
            "Select * from " + SEPARATOR + "exampleRegion r where r.positions['SUN'] != null")
        .execute());
    assertThat(results.size()).isEqualTo(2);
    assertThat(results.contains(p1)).isTrue();
    assertThat(results.contains(p3)).isTrue();
  }
Tests adding entries to compact range index where there are undefined and null values
for the key
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/CompactRangeIndexJUnitTest.java