code: private Document updateOrCreateIndexCollectionTypeEmbeddedObject(EntityMetadata metadata,
              final MetamodelImpl metaModel, Object entity, String parentId, Class<?> clazz, boolean isUpdate,
              Document document, Object embeddedObject, Object rowKey, String attributeName,
              EmbeddableType embeddableAttribute)
      {
          ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();
          // Check whether it's first time insert or updation
          if (ecCacheHandler.isCacheEmpty())
          { // First time
            // insert
              int count = 0;
              for (Object obj : (Collection<?>) embeddedObject)
              {
                  String elementCollectionObjectName = attributeName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + count;
  
                  document = prepareDocumentForSuperColumn(metadata, entity, elementCollectionObjectName, parentId, clazz);
                  createSuperColumnDocument(metadata, entity, document, obj, embeddableAttribute, metaModel);
                  if (isUpdate)
                  {
                      updateDocument(parentId, document, null);
                  }
                  else
                  {
                      indexDocument(metadata, document);
                  }
                  count++;
              }
          }
          else
          {
              // Updation, Check whether this object is already in
              // cache, which means we already have an embedded
              // column
              // Otherwise we need to generate a fresh embedded
              // column name
              int lastEmbeddedObjectCount = ecCacheHandler.getLastElementCollectionObjectCount(rowKey);
              for (Object obj : (Collection<?>) embeddedObject)
              {
                  document = indexCollectionObject(metadata, entity, parentId, clazz, isUpdate, rowKey, attributeName,
                          embeddableAttribute, ecCacheHandler, lastEmbeddedObjectCount, obj, metaModel);
              }
          }
          return document;
      }
docs: update or create indexes when embedded object is of collection type
  
  @param metadata
  @param metaModel
  @param entity
  @param parentId
  @param clazz
  @param isUpdate
  @param document
  @param embeddedObject
  @param rowKey
  @param attributeName
  @param embeddableAttribute
  @return