@Override
  public IndexInfo[] getIndexInfo(ExecutionContext context)
      throws TypeMismatchException, NameResolutionException {
    IndexInfo[] indexInfo = privGetIndexInfo(context);
    if (indexInfo != null) {
      if (indexInfo == NO_INDEXES_IDENTIFIER) {
        return null;
      } else {
        return indexInfo;
      }
    }

    if (!IndexUtils.indexesEnabled) {
      return null;
    }
    // get the path and index key to try
    PathAndKey pAndK = getPathAndKey(context);
    IndexInfo[] newIndexInfo = null;
    if (pAndK == null) {
      IndexData[] indexData =
          QueryUtils.getRelationshipIndexIfAny(_left, _right, context, _operator);// findOnlyFunctionalIndex.
      if (indexData != null) {
        newIndexInfo = new IndexInfo[2];
        for (int i = 0; i < 2; ++i) {
          newIndexInfo[i] = new IndexInfo(null, i == 0 ? _left : _right, indexData[i].getIndex(),
              indexData[i].getMatchLevel(), indexData[i].getMapping(),
              i == 0 ? _operator : reflectOperator(_operator));
        }
      }
    } else {
      CompiledValue path = pAndK._path;
      CompiledValue indexKey = pAndK._key;
      IndexData indexData;
      // CompiledLike should not use HashIndex and PrimarKey Index.
      if (this instanceof CompiledLike) {
        indexData =
            QueryUtils.getAvailableIndexIfAny(path, context, OQLLexerTokenTypes.LITERAL_like);
      } else {
        indexData = QueryUtils.getAvailableIndexIfAny(path, context, _operator);
      }

      if (indexCannotBeUsed(context, indexData)) {
        Index prIndex = ((AbstractIndex) indexData.getIndex()).getPRIndex();
        if (prIndex != null) {
          ((PartitionedIndex) prIndex).releaseIndexReadLockForRemove();
        } else {
          ((AbstractIndex) indexData.getIndex()).releaseIndexReadLockForRemove();
        }
        return null;
      }

      IndexProtocol index = null;
      if (indexData != null) {
        index = indexData.getIndex();
      }
      if (index != null && index.isValid()) {
        newIndexInfo = new IndexInfo[1];
        newIndexInfo[0] = new IndexInfo(indexKey, path, index, indexData.getMatchLevel(),
            indexData.getMapping(), reflectOnOperator(indexKey));
      }
    }
    if (newIndexInfo != null) {
      privSetIndexInfo(newIndexInfo, context);
    } else {
      privSetIndexInfo(NO_INDEXES_IDENTIFIER, context);
    }
    return newIndexInfo;
  }
evaluate as a filter, involving a two independent iterators. Use an index if possible on both.
And merge theresults obtained.
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java