public function index($collectionId, $type, array $attributes = [], $unique = false, array $indexOptions = [])
    {

        $urlParams  = [self::OPTION_COLLECTION => $collectionId];
        $bodyParams = [
            self::OPTION_TYPE   => $type,
            self::OPTION_FIELDS => $attributes,
        ];

        if ($unique !== null) {
            $bodyParams[self::OPTION_UNIQUE] = (bool) $unique;
        }

        $bodyParams = array_merge($bodyParams, $indexOptions);

        $url      = UrlHelper::appendParamsUrl(Urls::URL_INDEX, $urlParams);
        $response = $this->getConnection()->post($url, $this->json_encode_wrapper($bodyParams));

        $httpCode = $response->getHttpCode();
        switch ($httpCode) {
            case 404:
                throw new ClientException('Collection-identifier is unknown');

                break;
            case 400:
                throw new ClientException('cannot create unique index due to documents violating uniqueness');
                break;
        }

        return $response->getJson();
    }