Creates an index.

@param string $index
@param array $body

@return \Elastification\Client\Response\ResponseInterface
@author Daniel Wendlandt, Aurimas Niekis
168908
public function create($index, $body = null)
    {
        $request = $this->createRequestInstance(self::INDEX_CREATE, $index, null);

        if (null !== $body) {
            $request->setBody($body);
        }

        return $this->client->send($request);
    }
498702
public function addFilter($index, $method = null, ...$params)
    {
        $this->filters[$index] = [$method, $params];
        return $this;
    }
998654
def create_index(index_name, **kwargs):
    
    es = elasticsearch.Elasticsearch(**kwargs)
    es.indices.create(index=index_name, body=mapping)
    return connect(index_name, **kwargs)
1345683
public function createComment($body = null)
    {
        list($response, $statusCode, $httpHeader) = $this->createCommentWithHttpInfo ($body);
        return $response; 
    }
420958
def create(index_name, body, force, verbose):
    """"""
    result = current_search_client.indices.create(
        index=index_name,
        body=json.load(body),
        ignore=[400] if force else None,
    )
    if verbose:
        click.echo(json.dumps(result))
720622
public void createIndex(String index, boolean ignoreErrors, String indexSettings) throws IOException {
        logger.debug("create index [{}]", index);
        logger.trace("index settings: [{}]", indexSettings);
        CreateIndexRequest cir = new CreateIndexRequest(index);
        if (!isNullOrEmpty(indexSettings)) {
            cir.source(indexSettings, XContentType.JSON);
        }
        try {
            client.indices().create(cir, RequestOptions.DEFAULT);
        } catch (ElasticsearchStatusException e) {
            if (e.getMessage().contains("resource_already_exists_exception") && !ignoreErrors) {
                throw new RuntimeException("index already exists");
            }
            if (!e.getMessage().contains("resource_already_exists_exception")) {
                throw e;
            }
        }
        waitForHealthyIndex(index);
    }
388252
public function create($options = [])
    {
        $body = empty($options) ? $this->getDefaultIndexParams() : $options;

        self::getClient()->indices()->create(['index' => $this->getName(), 'body' => $body]);
    }
1303010
private static function requestApi($method, $body=null, $id=null) {
        $uri = Params::ENDPOINT . '/orders';
        if ($method == "get" || $method == "put")
            $uri .= "/$id";

        $request = new HttpRequest($method, $uri, self::$useSSL, self::$additionalCurlOpts);
        $request->setBasicAuthorization(self::$key);
        if (!is_null($body)) $request->setBodyAsJson($body);

        $response = $request->send();
        $response->checkCurlResponse();
        $jsonBody = $response->getBodyAsJson();
        if (!$response->isOk() || is_null($jsonBody) || !self::isBodyStatusOk($jsonBody)) {
            $httpStatus = $response->getHttpStatus();
            throw Exceptions\KondutoException::buildFromHttpStatus($jsonBody, $httpStatus);
        }

        return $response;
    }
1264382
protected function createIndex()
    {
        $configurator = $this->getIndexConfigurator();

        $payload = (new IndexPayload($configurator))
            ->setIfNotEmpty('body.settings', $configurator->getSettings())
            ->setIfNotEmpty('body.mappings._default_', $configurator->getDefaultMapping())
            ->get();

        ElasticClient::indices()
            ->create($payload);

        $this->info(sprintf(
            'The %s index was created!',
            $configurator->getName()
        ));
    }
1287017
final public function addIndex(Index $index): Table
    {
        if ($this->hasIndex($index::getName())) {
            throw new InvalidArgumentException('Foreign key '.$index::getName().' already exists in the table '.$this::getName());
        }

        $this->indexes[$index::getName()] = $index;

        return $this;
    }
263123
private boolean createIndex(String index, Map<String, Object> defaultSettings) {
        IndicesExistsResponse res = client.admin().indices().prepareExists(index).execute().actionGet();
        boolean created = false;
        if (!res.isExists()) {
            CreateIndexRequestBuilder req = client.admin().indices().prepareCreate(index);
            req.setSettings(defaultSettings);
            created = req.execute().actionGet().isAcknowledged();
            if (!created) {
                throw new RuntimeException("Could not create index [" + index + "]");
            }
        }

        return created;
    }
1048685
public function add($element, $index = null) {
		if ($index === null) {
			$this->collection[$this->size()] = $element;
		} else {
			array_splice($this->collection, $index, 0, $element);
		}
		
		return $this;
	}
1146404
public function addIndex($index)
    {
        if ($index instanceof Index) {
            $index = $index->getName();
        }

        if (!\is_scalar($index)) {
            throw new InvalidException('Invalid param type');
        }

        $this->_indices[] = (string) $index;

        return $this;
    }
766501
protected function createZedClient($index = null): Index
    {

        if ($index === null) {
            $index = Config::get(ConditionalAvailabilityConstants::ELASTICA_PARAMETER__INDEX_NAME);
        }

        return parent::createZedClient($index);
    }
416916
def create_index(self, index=None, settings=None, es=None):
        """"""
        if index is None:
            index = self.index
        if es is None:
            es = self.es
        try:
            alias = index
            index = generate_index_name(alias)

            args = {'index': index}
            if settings:
                args['body'] = settings

            es.indices.create(**args)
            es.indices.put_alias(index, alias)
            logger.info('created index alias=%s index=%s' % (alias, index))
        except elasticsearch.TransportError:  # index exists
            pass
1256889
public function newInstance($index)
    {
        $id = strtolower($index);
        if (!isset(static::$indexList[get_called_class()][$id])) {
            throw new \RuntimeException('No FileRequest found for: ' . $id);
        }
        $class = static::$indexList[get_called_class()][$id];
        return new $class;
    }
37346
public function add($element, $index = null)
    {
        if (null === $index || '' === $index) {
            $this->elements[] = $element;
        } else {
            $this->elements[$index] = $element;
        }

        return $this;
    }