Creates an index on a set of fields, if one does not already exist.

@param keys      an object with a key set of the fields desired for the index
@param optionsIN options for the index (name, unique, etc)
@throws MongoException If an error occurred
353355
public void ensureIndex(final DBObject keys, final DBObject optionsIN) throws MongoException {
        dbCollection.ensureIndex(keys, optionsIN);
    }
482031
def options
      OPTION_KEYS.inject({}){|o,k|o.merge!(k => send(k))}
    end
191677
function (key) {
      if (key === undefined) {
        that.push({
          key: 'DOCUMENT' + sep + docId + sep,
          lastPass: true
        })
        return end()
      }
      that.options.indexes.get(key, function (err, val) {
        if (!err) {
          that.push({
            key: key,
            value: val
          })
        }
        pushValue(docFields[i++])
      })
    }
595832
private void createUniqueIndexGFS(DBCollection coll, String id)
    {
        try
        {
            coll.createIndex(new BasicDBObject("metadata." + id, 1), new BasicDBObject("unique", true));
        }
        catch (MongoException ex)
        {
            throw new KunderaException("Error in creating unique indexes in " + coll.getFullName() + " collection on "
                    + id + " field");
        }
    }
984445
public MongoClient createMongoClient(MongoClientOptions options) {
		Integer embeddedPort = getEmbeddedPort();
		if (embeddedPort != null) {
			return createEmbeddedMongoClient(options, embeddedPort);
		}
		return createNetworkMongoClient(options);
	}
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))
449890
public function declareOptions( $optionKeys = array() )
	{
		if( !is_array( $optionKeys ) )
			throw new InvalidArgumentException( 'Option Keys must be an Array.' );
		foreach( $optionKeys as $key )
		{
			if( !is_string( $key ) )
				throw new InvalidArgumentException( 'Option Keys must be an Array List of Strings.' );
			$this->options[$key]	= NULL;
		}
	}
391107
function setQuery(map, options, query) {
  query = query || {};
  options = options || {};

  map.options.forEach(function eachOpts(opt) {
    Object.keys(opt).forEach(function eachOpt(key) {
      var param = opt[key],
          name = param.name,
          value = options[name] || options[key];

      if (value !== undefined && param.api) {
        if (param.array) {
          value = [].concat(value).join(' ');
        }
        query[param.api] = param.bool ? param.invert ?
          (value ? 0 : 1) : (value ? 1 : 0) : value;
      }
    });
  });

  return query;
}
268850
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = [])
    {
        $this->beginProfile($token = "    > create index $bucketName.$indexName ...");

        $result = $this->db->createIndex($bucketName, $indexName, $columns, $condition, $params, $options);

        $this->endProfile($token);

        return $result;
    }
153505
public function createSchemata(Collection $collection, array $schemata)
    {
        foreach ($schemata as $schema) {
            if (!isset($schema['keys']) || empty($schema['keys'])) {
                throw new \InvalidArgumentException('Cannot create an index with no keys defined.');
            }
            $schema['options']['background'] = true;
            $collection->ensureIndex($schema['keys'], $schema['options']);
        }
    }
918409
public void setIndexNames(java.util.Collection<String> indexNames) {
        if (indexNames == null) {
            this.indexNames = null;
            return;
        }

        this.indexNames = new java.util.ArrayList<String>(indexNames);
    }
401851
public function createIndex($collection, $columns, array $options = [])
    {
        $col = $this->db->selectCollection($collection);

        return $col->createIndex($columns, $options);
    }
509906
public void setKeys(java.util.Collection<String> keys) {
        if (keys == null) {
            this.keys = null;
            return;
        }

        this.keys = new java.util.ArrayList<String>(keys);
    }
116915
public void setIndexedAttributes(java.util.Collection<AttributeKeyAndValue> indexedAttributes) {
        if (indexedAttributes == null) {
            this.indexedAttributes = null;
            return;
        }

        this.indexedAttributes = new java.util.ArrayList<AttributeKeyAndValue>(indexedAttributes);
    }
787326
public function ensureIndex(array $keys, array $options = array())
    {
        $options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
        $options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
        $options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;

        return $this->riakCollection->ensureIndex($keys, $options);
    }
1330230
public function addIndex(array $columnNames, $indexName = null, array $flags = [], array $options = [])
    {
        if ($indexName === null) {
            $indexName = $this->_generateIdentifierName(
                array_merge([$this->getName()], $columnNames),
                'idx',
                $this->_getMaxIdentifierLength()
            );
        }

        return $this->_addIndex($this->_createIndex($columnNames, $indexName, false, false, $flags, $options));
    }
805244
function queryOptionsToMongo(query, options) {
    var hash = {},
        fields = fieldsToMongo(query[options.keywords.fields]),
        omitFields = omitFieldsToMongo(query[options.keywords.omit]),
        sort = sortToMongo(query[options.keywords.sort]),
        maxLimit = options.maxLimit || 9007199254740992,
        limit = options.maxLimit || 0

    if (fields) hash.fields = fields
    // omit intentionally overwrites fields if both have been specified in the query
    // mongo does not accept mixed true/fals field specifiers for projections
    if (omitFields) hash.fields = omitFields
    if (sort) hash.sort = sort

    if (query[options.keywords.offset]) hash.skip = Number(query[options.keywords.offset])
    if (query[options.keywords.limit]) limit = Math.min(Number(query[options.keywords.limit]), maxLimit)
    if (limit) {
        hash.limit = limit
    } else if (options.maxLimit) {
        hash.limit = maxLimit
    }

    return hash
}