Creates this index in the collection if it hasn't been already created
321398
def save(self):
        

        api = Client.instance().api

        index_details = {
            'type': self.index_type_obj.type_name
        }

        extra_index_attributes = self.index_type_obj.get_extra_attributes()

        for extra_attribute_key in extra_index_attributes:
            extra_attribute_value = extra_index_attributes[extra_attribute_key]
            index_details[extra_attribute_key] = extra_attribute_value

        query_parameters = {
            'collection': self.collection.name,
        }

        result = api.index.post(data=index_details, **query_parameters)

        self.index_type_obj.is_new = result['isNewlyCreated']
        self.index_type_obj.id = result['id']
598143
protected function createIndexes()
    {
        $this->addPrimaryKey(
            null,
            static::tableName(),
            [
                'elementId',
                'objectId',
                'fieldId',
                'siteId'
            ]
        );
        $this->createIndex(
            null,
            static::tableName(),
            'objectId',
            false
        );
    }
1010073
protected function remakeAutoIncrementIndex() : void
    {
        $nCollection = [];

        $c = 0;
        foreach ($this->collection as $val) {
            $nCollection[(string)$c] = $val;
            $c++;
        }

        $this->collection = $nCollection;
    }
1371761
def build_index(self, idx_name, _type='default'):
        ""
        indexes = {}
        has_non_string_values = False
        for key, item in self.data.items():
            if idx_name in item:
                value = item[idx_name]
                # A non-string index value switches it into a lazy one.
                if not isinstance(value, six.string_types):
                    has_non_string_values = True
                if value not in indexes:
                    indexes[value] = set([])
                indexes[value].add(key)
        self.indexes[idx_name] = indexes
        if self._meta.lazy_indexes or has_non_string_values:
            # Every index is lazy
            _type = 'lazy'
        self.index_defs[idx_name] = {'type': _type}
1362533
def create_indexes(cls, target=None, recreate=False):
		
		
		# TODO: Nested indexes.
		
		results = []
		collection = cls.get_collection(target)
		
		if recreate:
			collection.drop_indexes()
		
		for index in cls.__indexes__.values():
			results.append(index.create(collection))
		
		return results
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
240852
def create_indexed_document(index_instance, model_items, action):
    '''
    
    '''
    data = []
    if action == 'delete':
        for pk in model_items:
            data.append({'_id': pk, '_op_type': action})
    else:
        for doc in model_items:
            if index_instance.matches_indexing_condition(doc):
                data.append(index_instance.serialize_object(doc))
    return data
869059
function createIndexes() {
            // create listed indexes if they don't already exist.
            return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) {
                var entity = CRUD.EntityManager.entities[entityName];
                if (('indexes' in entity)) {
                    return Promise.all(entity.indexes.map(function(index) {
                        var indexName = index.replace(/\W/g, '') + '_idx';
                        if (!(entity.table in indexes) || indexes[entity.table].indexOf(indexName) == -1) {
                            return db.execute("create index if not exists " + indexName + " on " + entity.table + " (" + index + ")").then(function(result) {
                                CRUD.log("index created: ", entity.table, index, indexName);
                                if (!(entity.table in indexes)) {
                                    indexes[entity.table] = [];
                                }
                                indexes[entity.table].push(indexName);
                                return;
                            });
                        }
                        return;
                    }));
                }
            }));
        }
1059374
protected void initCollection() {
        boolean collectionExists = MongoUtils.collectionExists(getDatabase(), getCollectionName());
        if (!collectionExists) {
            LOGGER.info("Creating collection [" + getCollectionName() + "]...");
            getDatabase().createCollection(getCollectionName());
            MongoCollection<?> collection = getCollection();

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_ID + "]...");
            collection.createIndex(new Document().append(MongodbQueue.COLLECTION_FIELD_ID, 1),
                    new IndexOptions().unique(true));

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_EPHEMERAL_KEY + "]...");
            collection.createIndex(
                    new Document().append(MongodbQueue.COLLECTION_FIELD_EPHEMERAL_KEY, 1),
                    new IndexOptions());

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_QUEUE_TIME + "]...");
            collection.createIndex(
                    new Document().append(MongodbQueue.COLLECTION_FIELD_QUEUE_TIME, 1),
                    new IndexOptions());

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_TIME + "]...");
            collection.createIndex(new Document().append(MongodbQueue.COLLECTION_FIELD_TIME, 1),
                    new IndexOptions());

        }
    }
1318772
def ensure_indexes(self):
        """"""
        for collection_name in INDEXES:
            existing_indexes = self.indexes(collection_name)
            indexes = INDEXES[collection_name]
            for index in indexes:
                index_name = index.document.get('name')
                if index_name in existing_indexes:
                    logger.debug("Index exists: %s" % index_name)
                    self.db[collection_name].drop_index(index_name)
            logger.info("creating indexes for collection {0}: {1}".format(
                collection_name,
                ', '.join([index.document.get('name') for index in indexes]),
                )
            )
            self.db[collection_name].create_indexes(indexes)
712675
public void ensureIndex(String collName, String name, String fields, boolean unique, boolean dropDupsOnCreate) {

        BasicDBObject dbFields = parseFieldsString(fields);

        final BasicDBObjectBuilder keyOpts = new BasicDBObjectBuilder();
        if (name != null && name.length() != 0) {
            keyOpts.add("name", name);
        }
        if (unique) {
            keyOpts.add("unique", true);
            if (dropDupsOnCreate) {
                keyOpts.add("dropDups", true);
            }
        }

        final DBCollection dbColl = getCollection(getCollName(collName));

        final BasicDBObject opts = (BasicDBObject) keyOpts.get();
        if (opts.isEmpty()) {
            LOGGER.debug("Ensuring index for " + dbColl.getName() + " with keys:" + dbFields);
            dbColl.createIndex(dbFields);
        } else {
            LOGGER.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields + " and opts:" + opts);
            dbColl.createIndex(dbFields, opts);
        }
    }
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))
414091
function createFind(findIndexFunc) {
    return function(collection, predicate, fromIndex) {
      var iterable = Object(collection);
      predicate = baseIteratee(predicate, 3);
      if (!isArrayLike(collection)) {
        var props = keys(collection);
      }
      var index = findIndexFunc(props || collection, function(value, key) {
        if (props) {
          key = value;
          value = iterable[key];
        }
        return predicate(value, key, iterable);
      }, fromIndex);
      return index > -1 ? collection[props ? props[index] : index] : undefined;
    };
  }
776142
def index(name)
      indices[name] = Index.new(name) unless indices.include?(name)
    end
1022255
public void addSegDict(Collection<String> al) {
		for(String s: al){
			addDict(s);
		}
		createIndex();
	}
942555
public void createIndex(String collectionName, List<String> columnList, int order)
    {
        DBCollection coll = mongoDb.getCollection(collectionName);

        List<DBObject> indexes = coll.getIndexInfo(); // List of all current
        // indexes on collection
        Set<String> indexNames = new HashSet<String>(); // List of all current
        // index names
        for (DBObject index : indexes)
        {
            BasicDBObject obj = (BasicDBObject) index.get("key");
            Set<String> set = obj.keySet(); // Set containing index name which
            // is key
            indexNames.addAll(set);
        }

        // Create index if not already created
        for (String columnName : columnList)
        {
            if (!indexNames.contains(columnName))
            {
                KunderaCoreUtils.printQuery("Create index on:" + columnName, showQuery);
                coll.createIndex(new BasicDBObject(columnName, order));
            }
        }
    }
1029839
def create_index(self, index, index_type=GEO2D):
        
        self.logger.info("Adding %s index to stores on attribute: %s" % (index_type, index))
        yield self.collection.create_index([(index, index_type)])