Create index if it doesn't exist.
778725
def _create_index(self):
        """"""
        if not self.index_exists:
            index_settings = {}
            headers = {'Content-Type': 'application/json', 'DB-Method': 'POST'}
            url = '/v2/exchange/db/{}/{}'.format(self.domain, self.data_type)
            r = self.tcex.session.post(url, json=index_settings, headers=headers)

            if not r.ok:
                error = r.text or r.reason
                self.tcex.handle_error(800, [r.status_code, error])
            self.tcex.log.debug(
                'creating index. status_code: {}, response: "{}".'.format(r.status_code, r.text)
            )
374338
def create_index(index_definition, origin_module=Object)
			transaction {
				klass = if(index_definition.fulltext)
									FulltextIndex
								elsif(index_definition.resolve_search_term.is_a?(Hash))
									ConditionIndex
								else
									Index
								end
				index = klass.new(index_definition, origin_module)
				indices.store(index_definition.index_name, index)
				indices.odba_store_unsaved
				index
			}
		end
45049
def exists(self, index, doc_type, id, **query_params):
        
        path = make_path(index, doc_type, id)
        return self._send_request('HEAD', path, params=query_params)
1138451
def exists_query(expression):
    """"""
    def _exists(index, expression=expression):
        """Return store key for documents that satisfy expression."""
        ev = expression() if callable(expression) else expression
        if ev:
            return [
                store_key
                for store_keys
                in index.get_index().values()
                for store_key in store_keys
            ]
        else:
            return index.get_undefined_keys()

    return _exists
587815
def _add_index(self, index):
        
        index_name = index.get_name()
        index_name = self._normalize_identifier(index_name)
        replaced_implicit_indexes = []

        for name, implicit_index in self._implicit_indexes.items():
            if implicit_index.is_fullfilled_by(index) and name in self._indexes:
                replaced_implicit_indexes.append(name)

        already_exists = (
            index_name in self._indexes
            and index_name not in replaced_implicit_indexes
            or self._primary_key_name is not False
            and index.is_primary()
        )
        if already_exists:
            raise IndexAlreadyExists(index_name, self._name)

        for name in replaced_implicit_indexes:
            del self._indexes[name]
            del self._implicit_indexes[name]

        if index.is_primary():
            self._primary_key_name = index_name

        self._indexes[index_name] = index

        return self
246047
def put(index_name, doc_type, identifier, body, force, verbose):
    """"""
    result = current_search_client.index(
        index=index_name,
        doc_type=doc_type or index_name,
        id=identifier,
        body=json.load(body),
        op_type='index' if force or identifier is None else 'create',
    )
    if verbose:
        click.echo(json.dumps(result))
433755
def index(ctx, view):
    """"""
    adapter = ctx.obj['adapter']
    if view:
        click.echo(adapter.indexes())
        return
    adapter.ensure_indexes()
1326841
def create_index(self, cardinality):
        
        for i in reversed(range(cardinality)):
            if i != 0:
                query = "CREATE INDEX idx_{0}_gram_{1} ON _{0}_gram(word_{1});".format(cardinality, i)
                self.execute_sql(query)
607217
def _BuildIndex(self):
        """"""
        self._index = {}
        for i, k in enumerate(self._keys):
            self._index[k] = i
1350786
def _set_index(self, schema, name, fields, **index_options):
        
        query_str = "CREATE {}INDEX IF NOT EXISTS '{}_{}' ON {} ({})".format(
            'UNIQUE ' if index_options.get('unique', False) else '',
            schema,
            name,
            self._normalize_table_name(schema),
            ', '.join((self._normalize_name(f) for f in fields))
        )

        return self._query(query_str, ignore_result=True, **index_options)
1230965
public boolean isExistingIndex(String index) throws IOException {
        logger.debug("is existing index [{}]", index);
        GetIndexRequest gir = new GetIndexRequest();
        gir.indices(index);
        return client.indices().exists(gir, RequestOptions.DEFAULT);
    }
402074
def index_from_id(self,Id):
        """"""
        try:
            return [a.Id for a in self].index(Id)
        except IndexError:
            return
160267
def find_by_index(self, cls, index_name, value):
        """"""
        return self.backend.find_by_index(cls, index_name, value)
991192
def find_by_index(self, cls, index_name, value):
        """"""
        cur = self._conn().cursor()

        query = 'select id,value from %s where %s = ?' % (
            cls.get_table_name(),
            index_name
        )

        found = []
        for row in cur.execute(query, (value,)):
            id, data = row[0], row[1]
            obj = cls.from_data(data)
            assert id == obj.id
            found.append(obj)

        cur.close()

        return found
1228936
def exists_alias(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.exists_alias(index=self._name, **kwargs)
283372
def index_exists(engine: Engine, tablename: str, indexname: str) -> bool:
    
    insp = Inspector.from_engine(engine)
    return any(i['name'] == indexname for i in insp.get_indexes(tablename))
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)