Creates an index if it doesn't already exist.

        If supplied, settings must be a dictionary.

        :param index: the name of the index
        :keyword settings: a settings object or a dict containing settings
322034
def create_index_if_missing(self, index, settings=None):
        
        try:
            return self.create_index(index, settings)
        except IndexAlreadyExistsException as e:
            return e.result
1029025
def check_index(self, key, *, index):
        
        self.append({
            "Verb": "check-index",
            "Key": key,
            "Index": extract_attr(index, keys=["ModifyIndex", "Index"])
        })
        return self
1194998
@When("^I create an elasticsearch index named '(.+?)'( removing existing index if exist)?$")
    public void createElasticsearchIndex(String index, String removeIndex) {
        if (removeIndex != null && commonspec.getElasticSearchClient().indexExists(index)) {
            commonspec.getElasticSearchClient().dropSingleIndex(index);
        }
        commonspec.getElasticSearchClient().createSingleIndex(index);
    }
33221
def index(self, index):
        
        if self._index != index:
            self._dirty = True
        self._index = index
680051
def get_index(self, name):
        
        name = self._normalize_identifier(name)
        if not self.has_index(name):
            raise IndexDoesNotExist(name, self._name)

        return self._indexes[name]
758231
def _CreateIndexIfNotExists(self, index_name, mappings):
    
    try:
      if not self._client.indices.exists(index_name):
        self._client.indices.create(
            body={'mappings': mappings}, index=index_name)

    except elasticsearch.exceptions.ConnectionError as exception:
      raise RuntimeError(
          'Unable to create Elasticsearch index with error: {0!s}'.format(
              exception))
99541
def create(self):
        """"""
        body = dict()
        if self.mapping is not None:
            body['mappings'] = self.mapping
        if self.settings is not None:
            body['settings'] = self.settings
        else:
            body['settings'] = self._default_settings()
        self.instance.indices.create(self.index, body)
395799
def update_index(self, name, value):
        
        kwargs = {}
        kwargs['index.' + name] = value if isinstance(value, basestring) else json.dumps(value)
        return self.post(**kwargs)
576929
@Deprecated
	private static void updateIndexWithSettingsInElasticsearch(Client client, String index, String settings) throws Exception {
		logger.trace("updateIndex([{}])", index);

		assert client != null;
		assert index != null;

		if (settings != null) {
			logger.trace("Found update settings for index [{}]: [{}]", index, settings);
			logger.debug("updating settings for index [{}]", index);
			client.admin().indices().prepareUpdateSettings(index).setSettings(settings, XContentType.JSON).get();
		}

		logger.trace("/updateIndex([{}])", index);
	}
15173
def addIndex(self, index):
        
        index.setSchema(self)
        self.__indexes[index.name()] = index
1290329
def make_index(name, localname):
    
    return type("BB%sIndex" % (name.capitalize(),),
                (BBIndex,),
                dict(name=name, localname=localname))
360739
def has_index(self, name):
        
        name = self._normalize_identifier(name)

        return name in self._indexes
1199862
def create_index(config):
    """"""
    filename = pathlib.Path(config.cache_path) / "index.json"
    index = {"version": __version__}
    with open(filename, "w") as out:
        out.write(json.dumps(index, indent=2))
928345
def exists(self, index):
        
        data = self.data
        try:
            for c in self._split(index):
                i = int(c) - 1
                data = data[i][4]
        except Exception:
            return False
        return True
796514
def create_index(self,
                     table: str,
                     field: str,
                     nchars: int = None,
                     indexname: str = None,
                     unique: bool = False) -> Optional[int]:
        """"""
        limit = ""
        if nchars is not None:
            limit = "({})".format(nchars)
        if indexname is None:
            indexname = "_idx_{}".format(field)
        if self.index_exists(table, indexname):
            return None
        uniquestr = "UNIQUE" if unique else ""
        sql = (
            "CREATE {unique} INDEX {indexname} "
            "ON {table} ({field}{limit})".format(
                unique=uniquestr,
                indexname=indexname,
                table=table,
                field=field,
                limit=limit,
            )
        )
        return self.db_exec(sql)
1166230
def AddIndex(node, index=None):
  
  if isinstance(node, list):
    for i, item in enumerate(node):
      AddIndex(item, index=i)
  elif isinstance(node, dict):
    if index is not None:
      node['index'] = index
    for key in node:
      AddIndex(node[key])
618282
def remove_index(self, index):
        ''
        index_rm, single = convert_key_to_index(force_list(self.indices.keys()), index)
        if single:
            index_rm = [index_rm]

        index_new = [i for i in range(len(self.indices)) if i not in index_rm]

        if not index_new: # no index left
            self.clear(True)
            return

        names = mget_list(force_list(self.indices.keys()), index_new)
        items = [mget_list(i, index_new) for i in self.items()]
        self.clear(True)
        _MI_init(self, items, names)