@Test
  public void testBug38422() throws Exception {
    QueryService qs;
    qs = CacheUtils.getQueryService();
    Region rgn = CacheUtils.getRegion(SEPARATOR + "pos");
    // The region already contains 3 Portfolio object. The 4th Portfolio object
    // has its status field explictly made null. Thus the query below will result
    // in intersection of two non empty sets. One which contains 4th Portfolio
    // object containing null status & the second condition does not contain the
    // 4th portfolio object
    Portfolio pf = new Portfolio(4);
    pf.status = null;
    rgn.put(4, pf);
    String queryStr =
        "select  * from " + SEPARATOR + "pos pf where pf.status != 'active' and pf.status != null";

    SelectResults[][] r = new SelectResults[1][2];
    Query qry = qs.newQuery(queryStr);
    SelectResults sr = null;
    sr = (SelectResults) qry.execute();
    r[0][0] = sr;
    qs.createIndex("statusIndx", IndexType.FUNCTIONAL, "pf.status", SEPARATOR + "pos pf");
    sr = null;
    sr = (SelectResults) qry.execute();
    r[0][1] = sr;
    CacheUtils.compareResultsOfWithAndWithoutIndex(r, this);
    assertEquals(2, (r[0][0]).size());
    assertEquals(2, (r[0][1]).size());
  }
Tests the Bug 38422 where the index results intersection results in incorrect size

<p>
TRAC #38422: Non distinct select query may return a ResultsBag with incorrect size depending on
the where clause
geode-core/src/integrationTest/java/org/apache/geode/cache/query/QueryServiceRegressionTest.java