@Test
  public void testEquijoinPRColocatedQuery_2() throws Exception {

    AttributesFactory factory = new AttributesFactory();
    factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(1)
        .setTotalNumBuckets(40).setPartitionResolver(new PartitionResolver() {

          @Override
          public String getName() {
            return "blah";
          }

          @Override
          public Serializable getRoutingObject(EntryOperation opDetails) {
            return (Serializable) opDetails.getKey();
          }

          @Override
          public void close() {

        }

        }).create());
    PartitionedRegion pr1 =
        (PartitionedRegion) CacheUtils.getCache().createRegion("pr1", factory.create());
    factory = new AttributesFactory();
    factory.setPartitionAttributes(new PartitionAttributesFactory()

        .setRedundantCopies(1).setTotalNumBuckets(40).setPartitionResolver(new PartitionResolver() {

          @Override
          public String getName() {
            return "blah";
          }

          @Override
          public Serializable getRoutingObject(EntryOperation opDetails) {
            return (Serializable) opDetails.getKey();
          }

          @Override
          public void close() {

        }

        }).setColocatedWith(pr1.getName()).create());

    final PartitionedRegion pr2 =
        (PartitionedRegion) CacheUtils.getCache().createRegion("pr2", factory.create());

    createAllNumPRAndEvenNumPR(pr1, pr2, 80);
    Set<Integer> set = createAndPopulateSet(15);
    LocalDataSet lds = new LocalDataSet(pr1, set);

    QueryObserverImpl observer = new QueryObserverImpl();
    QueryObserverHolder.setInstance(observer);
    QueryService qs = pr1.getCache().getQueryService();

    qs.createIndex("valueIndex", IndexType.FUNCTIONAL, "e.value", SEPARATOR + "pr1.entries e");
    qs.createIndex("valueIndex", IndexType.FUNCTIONAL, "e.value", SEPARATOR + "pr2.entries e");
    String query =
        "select distinct e1.key from " + SEPARATOR + "pr1.entries e1," + SEPARATOR
            + "pr2.entries  e2" + " where e1.value=e2.value";
    DefaultQuery cury = (DefaultQuery) CacheUtils.getQueryService().newQuery(query);
    final ExecutionContext executionContext =
        new QueryExecutionContext(null, (InternalCache) cache, cury);
    SelectResults r = (SelectResults) lds.executeQuery(cury, executionContext, null, set);

    if (!observer.isIndexesUsed) {
      fail("Indexes should have been used");
    }
  }
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