code: private void addRelationshipIndex(EntityMetadata entityMetadata, Relationship relationship,
              Index<Relationship> relationshipIndex, MetamodelImpl metaModel)
      {
  //        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
  //                entityMetadata.getPersistenceUnit());
  
          // ID attribute has to be indexed first
          String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
          relationshipIndex.add(relationship, idColumnName, relationship.getProperty(idColumnName));
  
          // Index all other fields, for whom indexing is enabled
          for (Attribute attribute : metaModel.entity(entityMetadata.getEntityClazz()).getSingularAttributes())
          {
              Field field = (Field) attribute.getJavaMember();
              if (!attribute.isCollection() && !attribute.isAssociation()
                      && entityMetadata.getIndexProperties().keySet().contains(field.getName()))
              {
                  String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
                  relationshipIndex.add(relationship, columnName, relationship.getProperty(columnName));
              }
          }
      }
docs: Adds Relationship Index for all singular attributes (including ID) of a
  given relationship entity
  
  @param entityMetadata
  @param graphDb
  @param relationship