src/Sherlock/requests/IndexRequest.php
public function create()
    {

        if (!isset($this->params['index']))
            throw new exceptions\RuntimeException("Index cannot be empty.");

        $index = implode(',', $this->params['index']);

        //Final JSON should be object properties, not an array.  So we need to iterate
        //through the array members and merge into an associative array.
        $mappings = array();
        foreach ($this->params['indexMappings'] as $type => $mapping) {
            $mappings = array_merge($mappings, array($type => $mapping));
        }
        $body = array(
            "settings" => $this->params['indexSettings'],
            "mappings" => $mappings
        );

        $command = new Command();
        $command->index($index)
            ->action('put')
            ->data(json_encode($body, JSON_FORCE_OBJECT));

        $this->batch->clearCommands();
        $this->batch->addCommand($command);

        /**
         * @var \Sherlock\responses\IndexResponse
         */
        $ret = parent::execute();

        //clear out mappings, settings
        $this->resetIndex();

        return $ret[0];
    }
public function create()
    {

        if (!isset($this->params['index']))
            throw new exceptions\RuntimeException("Index cannot be empty.");

        $index = implode(',', $this->params['index']);

        //Final JSON should be object properties, not an array.  So we need to iterate
        //through the array members and merge into an associative array.
        $mappings = array();
        foreach ($this->params['indexMappings'] as $type => $mapping) {
            $mappings = array_merge($mappings, array($type => $mapping));
        }
        $body = array(
            "settings" => $this->params['indexSettings'],
            "mappings" => $mappings
        );

        $command = new Command();
        $command->index($index)
            ->action('put')
            ->data(json_encode($body, JSON_FORCE_OBJECT));

        $this->batch->clearCommands();
        $this->batch->addCommand($command);

        /**
         * @var \Sherlock\responses\IndexResponse
         */
        $ret = parent::execute();

        //clear out mappings, settings
        $this->resetIndex();

        return $ret[0];
    }
Create an index

@return \Sherlock\responses\IndexResponse
@throws exceptions\RuntimeException