Friday, 24 September 2021

ArangoDB: Get all the indexes of a collection

'getIndexes()'  (or) ‘indexes()’method return all the indexes of a collection.

 

Example 1: Let’s create an employee collection and get the indexes.

127.0.0.1:8529@abc_org> db._create("employees")
[ArangoCollection 77247, "employees" (type document, status loaded)]

127.0.0.1:8529@abc_org> db.employees.getIndexes()
[ 
  { 
    "fields" : [ 
      "_key" 
    ], 
    "id" : "employees/0", 
    "name" : "primary", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "primary", 
    "unique" : true 
  } 
]

  Example 2: Let’s create an reportsTo edge collection and get the indexes.

 

127.0.0.1:8529@abc_org> db._createEdgeCollection("reportsTo")
[ArangoCollection 77307, "reportsTo" (type edge, status loaded)]

127.0.0.1:8529@abc_org> db.reportsTo.getIndexes()
[ 
  { 
    "fields" : [ 
      "_key" 
    ], 
    "id" : "reportsTo/0", 
    "name" : "primary", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "primary", 
    "unique" : true 
  }, 
  { 
    "fields" : [ 
      "_from", 
      "_to" 
    ], 
    "id" : "reportsTo/2", 
    "name" : "edge", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "edge", 
    "unique" : false 
  } 
]

Using indexes method

127.0.0.1:8529@abc_org> db.employees.indexes()
[ 
  { 
    "fields" : [ 
      "_key" 
    ], 
    "id" : "employees/0", 
    "name" : "primary", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "primary", 
    "unique" : true 
  } 
]

127.0.0.1:8529@abc_org> db.reportsTo.indexes()
[ 
  { 
    "fields" : [ 
      "_key" 
    ], 
    "id" : "reportsTo/0", 
    "name" : "primary", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "primary", 
    "unique" : true 
  }, 
  { 
    "fields" : [ 
      "_from", 
      "_to" 
    ], 
    "id" : "reportsTo/2", 
    "name" : "edge", 
    "selectivityEstimate" : 1, 
    "sparse" : false, 
    "type" : "edge", 
    "unique" : false 
  } 
]



 

Previous                                                    Next                                                    Home

No comments:

Post a Comment