private UpdateResult shardUpdateOperation(
     ClusterState clusterState,
     BulkShardRequest bulkShardRequest,
     UpdateRequest updateRequest,
     IndexShard indexShard) {
   UpdateHelper.Result translate = updateHelper.prepare(updateRequest, indexShard);
   switch (translate.operation()) {
     case UPSERT:
     case INDEX:
       IndexRequest indexRequest = translate.action();
       try {
         WriteResult result =
             shardIndexOperation(bulkShardRequest, indexRequest, clusterState, indexShard, false);
         return new UpdateResult(translate, indexRequest, result);
       } catch (Throwable t) {
         t = ExceptionsHelper.unwrapCause(t);
         boolean retry = false;
         if (t instanceof VersionConflictEngineException
             || (t instanceof DocumentAlreadyExistsException
                 && translate.operation() == UpdateHelper.Operation.UPSERT)) {
           retry = true;
         }
         return new UpdateResult(translate, indexRequest, retry, t, null);
       }
     case DELETE:
       DeleteRequest deleteRequest = translate.action();
       try {
         WriteResult result = shardDeleteOperation(bulkShardRequest, deleteRequest, indexShard);
         return new UpdateResult(translate, deleteRequest, result);
       } catch (Throwable t) {
         t = ExceptionsHelper.unwrapCause(t);
         boolean retry = false;
         if (t instanceof VersionConflictEngineException) {
           retry = true;
         }
         return new UpdateResult(translate, deleteRequest, retry, t, null);
       }
     case NONE:
       UpdateResponse updateResponse = translate.action();
       indexShard.indexingService().noopUpdate(updateRequest.type());
       return new UpdateResult(translate, updateResponse);
     default:
       throw new IllegalStateException("Illegal update operation " + translate.operation());
   }
 }