MongoCollection::getIndexInfo

(PECL mongo >=0.9.0)

MongoCollection::getIndexInfoReturns information about indexes on this collection

Açıklama

public MongoCollection::getIndexInfo ( void ) : array

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

This function returns an array in which each element describes an index. Elements will contain the values name for the name of the index, ns for the namespace (a combination of the database and collection name), and key for a list of all fields in the index and their ordering. Additional values may be present for special indexes, such as unique or sparse.

Örnekler

Örnek 1 MongoCollection::getIndexInfo() example

<?php

$m 
= new MongoClient();
$c $m->selectCollection('test''venues');
var_dump($c->getIndexInfo());

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

array(4) {
  [0]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["_id"]=>
      int(1)
    }
    ["name"]=>
    string(4) "_id_"
    ["ns"]=>
    string(11) "test.venues"
  }
  [1]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["name"]=>
      float(1)
    }
    ["name"]=>
    string(6) "name_1"
    ["ns"]=>
    string(11) "test.venues"
  }
  [2]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(2) {
      ["type"]=>
      float(1)
      ["createdAt"]=>
      float(-1)
    }
    ["name"]=>
    string(19) "type_1_createdAt_-1"
    ["ns"]=>
    string(11) "test.venues"
  }
  [3]=>
  array(5) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["location"]=>
      string(8) "2dsphere"
    }
    ["name"]=>
    string(17) "location_2dsphere"
    ["ns"]=>
    string(11) "test.venues"
    ["2dsphereIndexVersion"]=>
    int(2)
  }
}

Ayrıca Bakınız

MongoDB core docs on » vanilla indexes and » geospatial indexes.

add a note add a note

User Contributed Notes 1 note

up
1
nanhe dot kumar at gmail dot com
11 years ago
<?php
/*
    For example, to view all indexes on the people collection from country databse :
    InmongoDb
    use country
    db.people.getIndexes()
    Inphp

*/
$m = new MongoClient();
$indexes = $m->country->people->getIndexInfo();

?>
To Top