|
MongoCollection::ensureIndex(PECL mongo >=0.9.0) MongoCollection::ensureIndex — Creates an index on the given field(s), or does nothing if the index already exists Описание
public bool MongoCollection::ensureIndex
( string|array $key|keys
[, array $options = array()
] )
This method creates an index on the collection and the specified fields. The key specification can either be just a single field name as string, or an array containing one or more field names with their sort direction. Список параметров
Возвращаемые значенияReturns TRUE. Список изменений
ОшибкиThrows MongoException if the index name is longer than 128 bytes. (Version 1.0.11+) Throws MongoCursorException if the "safe" option is set and the index creation fails. Throws MongoCursorTimeoutException if the "safe" option is set and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. ПримерыПример #1 MongoCollection::ensureIndex() example
<?php Пример #2 Drop duplicates example
<?php Пример #3 Geospatial Indexing Mongo supports geospatial indexes, which allow you to search for documents near a given location or within a shape. For example, to create a geospatial index on the "loc" field:
<?php Смотрите такжеMongoDB core docs on » vanilla indexes and » geospatial indexes. |
|||||||||||||