1
0
Fork 0
arangodb/Documentation/Books/Users/IndexHandling/WorkingWithIndexes.mdpp

61 lines
1.9 KiB
Plaintext

!CHAPTER Working with Indexes
!SECTION Index Identifiers and Handles
An *index handle* uniquely identifies an index in the database. It is a string and
consists of the collection name and an *index identifier* separated by a `/`. The
index identifier part is a numeric value that is auto-generated by ArangoDB.
A specific index of a collection can be accessed using its *index handle* or
*index identifier* as follows:
```js
db.collection.index("<index-handle>");
db.collection.index("<index-identifier>");
db._index("<index-handle>");
```
For example: Assume that the index handle, which is stored in the `_id`
attribute of the index, is `demo/362549736` and the index was created in a collection
named `demo`. Then this index can be accessed as:
```js
db.demo.index("demo/362549736");
```
Because the index handle is unique within the database, you can leave out the
*collection* and use the shortcut:
```js
db._index("demo/362549736");
```
!SECTION Collection Methods
!SUBSECTION Listing all indexes of a collection
<!-- arangod/V8Server/v8-vocindex.cpp -->
@startDocuBlock collectionGetIndexes
!SUBSECTION Creating an index
Indexes can be created using the general method *ensureIndex*, or *ensure&lt;type&gt;Index* (see the respective subchapters that also describe the behavior of this index in more detail.
<!-- arangod/V8Server/v8-vocindex.cpp -->
@startDocuBlock collectionEnsureIndex
!SUBSECTION Dropping an index
<!-- arangod/V8Server/v8-vocindex.cpp -->
@startDocuBlock col_dropIndex
!SECTION Database Methods
!SUBSECTION Fetching an index by handle
<!-- js/server/modules/org/arangodb/arango-database.js -->
@startDocuBlock IndexHandle
!SUBSECTION Dropping an index
<!-- js/server/modules/org/arangodb/arango-database.js -->
@startDocuBlock dropIndex
!SUBSECTION Revalidating whether an index is used
<!-- js/server/modules/org/arangodb/arango-database.js -->
@startDocuBlock IndexVerify