Modifying a Collection

Load collection

loads a collection

PUT /_api/collection/{collection-name}/load

The load function is deprecated from version 3.8.0 onwards and should no longer be used.

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Path Parameters

  • collection-name (required): The name of the collection.

Loads a collection into memory. Returns the collection on success.

The request body object might optionally contain the following attribute:

  • count: If set, this controls whether the return value should include the number of documents in the collection. Setting count to false may speed up loading a collection. The default value for count is true.

On success an object with the following attributes is returned:

  • id: The identifier of the collection.

  • name: The name of the collection.

  • count: The number of documents inside the collection. This is only returned if the count input parameters is set to true or has not been specified.

  • status: The status of the collection as number.

  • type: The collection type. Valid types are:
    • 2: document collection
    • 3: edges collection
  • isSystem: If true then the collection is a system collection.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/load

HTTP/1.1 200 OK
content-type: application/json
connection: Keep-Alive
content-length: 145
location: /_api/collection/products/load
server: ArangoDB
x-content-type-options: nosniff
Show response body

Unload collection

unloads a collection

PUT /_api/collection/{collection-name}/unload

The unload function is deprecated from version 3.8.0 onwards and should no longer be used.

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Path Parameters

  • collection-name (required): Removes a collection from memory. This call does not delete any documents. You can use the collection afterwards; in which case it will be loaded into memory, again. On success an object with the following attributes is returned:

  • id: The identifier of the collection.

  • name: The name of the collection.

  • status: The status of the collection as number.

  • type: The collection type. Valid types are:
    • 2: document collection
    • 3: edges collection
  • isSystem: If true then the collection is a system collection.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/unload

HTTP/1.1 200 OK
content-type: application/json
connection: Keep-Alive
content-length: 135
location: /_api/collection/products/unload
server: ArangoDB
x-content-type-options: nosniff
Show response body

Load Indexes into Memory

Load Indexes into Memory

PUT /_api/collection/{collection-name}/loadIndexesIntoMemory

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Path Parameters

  • collection-name (required): This route tries to cache all index entries of this collection into the main memory. Therefore it iterates over all indexes of the collection and stores the indexed values, not the entire document data, in memory. All lookups that could be found in the cache are much faster than lookups not stored in the cache so you get a nice performance boost. It is also guaranteed that the cache is consistent with the stored data.

For the time being this function is only useful on RocksDB storage engine, as in MMFiles engine all indexes are in memory anyways.

On RocksDB this function honors all memory limits, if the indexes you want to load are smaller than your memory limit this function guarantees that most index values are cached. If the index is larger than your memory limit this function will fill up values up to this limit and for the time being there is no way to control which indexes of the collection should have priority over others.

On sucess this function returns an object with attribute result set to true

Return codes

  • 200: If the indexes have all been loaded

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/loadIndexesIntoMemory

HTTP/1.1 200 OK
content-type: application/json
connection: Keep-Alive
content-length: 40
location: /_api/collection/products/loadIndexesIntoMemory
server: ArangoDB
x-content-type-options: nosniff
Show response body

Change properties of a collection

changes a collection

PUT /_api/collection/{collection-name}/properties

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Path Parameters

  • collection-name (required): The name of the collection.

Changes the properties of a collection. Expects an object with the attribute(s)

  • waitForSync: If true then creating or changing a document will wait until the data has been synchronized to disk.

  • schema: Object that specifies the collection level schema for documents. The attribute keys rule, level and message must follow the rules documented in Document Schema Validation

On success an object with the following attributes is returned:

  • id: The identifier of the collection.

  • name: The name of the collection.

  • waitForSync: The new value.

  • status: The status of the collection as number.

  • type: The collection type. Valid types are:
    • 2: document collection
    • 3: edges collection
  • isSystem: If true then the collection is a system collection.

  • keyOptions: JSON object which contains key generation options:
    • type: specifies the type of the key generator. The currently available generators are traditional, autoincrement, uuid and padded.
    • allowUserKeys: if set to true, then it is allowed to supply own key values in the _key attribute of a document. If set to false, then the key generator is solely responsible for generating keys and supplying own key values in the _key attribute of documents is considered an error.
  • schema (optional, default is null): Object that specifies the collection level schema for documents. The attribute keys rule, level and message must follow the rules documented in Document Schema Validation

Note: except for waitForSync and name, collection properties cannot be changed once a collection is created. To rename a collection, the rename endpoint must be used.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/collection/products/properties <<EOF
{ 
  "waitForSync" : true 
}
EOF

HTTP/1.1 200 OK
content-type: application/json
connection: Keep-Alive
content-length: 416
location: /_api/collection/products/properties
server: ArangoDB
x-content-type-options: nosniff
Show response body

Rename collection

renames a collection

PUT /_api/collection/{collection-name}/rename

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Path Parameters

  • collection-name (required): The name of the collection to rename.

Renames a collection. Expects an object with the attribute(s)

  • name: The new name.

It returns an object with the attributes

  • id: The identifier of the collection.

  • name: The new name of the collection.

  • status: The status of the collection as number.

  • type: The collection type. Valid types are:
    • 2: document collection
    • 3: edges collection
  • isSystem: If true then the collection is a system collection.

If renaming the collection succeeds, then the collection is also renamed in all graph definitions inside the _graphs collection in the current database.

Note: this method is not available in a cluster.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/collection/products1/rename <<EOF
{ 
  "name" : "newname" 
}
EOF

HTTP/1.1 200 OK
content-type: application/json
connection: Keep-Alive
content-length: 134
location: /_api/collection/products1/rename
server: ArangoDB
x-content-type-options: nosniff
Show response body

Recalculate count of a collection

recalculates the document count of a collection

PUT /_api/collection/{collection-name}/recalculateCount

Path Parameters

  • collection-name (required): The name of the collection.

Recalculates the document count of a collection, if it ever becomes inconsistent.

It returns an object with the attributes

  • result: will be true if recalculating the document count succeeded.

Note: this method is specific for the RocksDB storage engine

Return codes

  • 200: If the document count was recalculated successfully, HTTP 200 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.