public CacheSerializableRunnable getCacheSerializableRunnableForPRIndexCreate(
      final String prRegionName, final String indexName, final String indexedExpression,
      final String fromClause, final String alias) {

    SerializableRunnable prIndexCreator = new CacheSerializableRunnable("PartitionedIndexCreator") {
      @Override
      public void run2() {
        try {
          Cache cache = getCache();
          QueryService qs = cache.getQueryService();
          Region region = cache.getRegion(prRegionName);
          LogWriter logger = cache.getLogger();
          if (null != fromClause) {
            logger.info("Test Creating index with Name : [ " + indexName + " ] "
                + "IndexedExpression : [ " + indexedExpression + " ] Alias : [ " + alias
                + " ] FromClause : [ " + fromClause + " " + alias + " ] ");
            Index parIndex =
                qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause);
            logger.info("Index creted on partitioned region : " + parIndex);
          } else {
            logger.info("Test Creating index with Name : [ " + indexName + " ] "
                + "IndexedExpression : [ " + indexedExpression + " ] Alias : [ " + alias
                + " ] FromClause : [ " + region.getFullPath() + " " + alias + " ] ");
            Index parIndex = qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression,
                region.getFullPath() + " " + alias);
            logger.info("Index creted on partitioned region : " + parIndex);
            logger.info("Number of buckets indexed in the partitioned region locally : " + ""
                + ((PartitionedIndex) parIndex).getNumberOfIndexedBuckets()
                + " and remote buckets indexed : "
                + ((PartitionedIndex) parIndex).getNumRemoteBucketsIndexed());
          }
          /*
           * assertIndexDetailsEquals("Max num of buckets in the partiotion regions and the
           * " + "buckets indexed should be equal",
           * ((PartitionedRegion)region).getTotalNumberOfBuckets(),
           * (((PartionedIndex)parIndex).getNumberOfIndexedBucket()+((PartionedIndex)parIndex).
           * getNumRemtoeBucketsIndexed())); should put all the assetion in a separate function.
           */
        } catch (Exception ex) {
          Assert.fail("Creating Index in this vm failed : ", ex);
        }
      }
    };
    return (CacheSerializableRunnable) prIndexCreator;
  }
This function creates a appropriate index on a PR given the name and other parameters.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java