云搜索删除文档php

时间:2018-07-16 10:15:21

标签: php amazon-web-services amazon-cloudformation

我具有以下删除对象的功能。我想知道如何使用状态将idArray传递给此函数?

function deleteDocs($idArray, $operation = 'delete'){
    $batch = array();

    foreach($idArray as $id){
        $batch[] = array(
                    'type'        => $operation,
                    'id'        => $id);                       
    }
    $batch = array_filter($batch);
    $jsonObj = json_encode($batch, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);

    $result = $this->client->uploadDocuments(array(
                    'documents'     => $jsonObj,
                    'contentType'     =>'application/json'
                ));

    return $result['status'] == 'success' ? mb_strlen($jsonObj) : 0;
} 

0 个答案:

没有答案