Modifying a Collection

Load collection

loads a collection

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

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.

Example:

shell> curl -X PUT --dump - http://localhost:8529/_api/collection/products/load

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/load

{ 
  "code" : 200, 
  "error" : false, 
  "type" : 2, 
  "globallyUniqueId" : "h68719E5AC6E7/10426", 
  "count" : 0, 
  "status" : 3, 
  "id" : "10426", 
  "isSystem" : false, 
  "name" : "products" 
}

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 --dump - http://localhost:8529/_api/collection/products/load

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/load

show response body

Unload collection

unloads a collection

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

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.

Example:

shell> curl -X PUT --dump - http://localhost:8529/_api/collection/products/unload

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/unload

{ 
  "code" : 200, 
  "error" : false, 
  "status" : 4, 
  "name" : "products", 
  "type" : 2, 
  "globallyUniqueId" : "h68719E5AC6E7/10470", 
  "isSystem" : false, 
  "id" : "10470" 
}

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 --dump - http://localhost:8529/_api/collection/products/unload

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/unload

show response body

Load Indexes into Memory

Load Indexes into Memory

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

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

Example:

shell> curl -X PUT --dump - http://localhost:8529/_api/collection/products/loadIndexesIntoMemory

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/loadIndexesIntoMemory

{ 
  "code" : 200, 
  "error" : false, 
  "result" : 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 --dump - http://localhost:8529/_api/collection/products/loadIndexesIntoMemory

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/loadIndexesIntoMemory

show response body

Change properties of a collection

changes a collection

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

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.

  • journalSize: The maximal size of a journal or datafile in bytes. The value must be at least 1048576 (1 MB). Note that when changing the journalSize value, it will only have an effect for additional journals or datafiles that are created. Already existing journals or datafiles will not be affected.

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.

  • journalSize: 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.

  • isVolatile: If true then the collection data will be kept in memory only and ArangoDB will not write or sync the data to disk.

  • doCompact: Whether or not the collection will be compacted.

  • keyOptions: JSON object which contains key generation options:

    • type: specifies the type of the key generator. The currently available generators are traditional and autoincrement.
    • 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.

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

Example:

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

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/properties

{ 
  "code" : 200, 
  "error" : false, 
  "status" : 3, 
  "statusString" : "loaded", 
  "name" : "products", 
  "keyOptions" : { 
    "type" : "traditional", 
    "allowUserKeys" : true, 
    "lastValue" : 0 
  }, 
  "type" : 2, 
  "indexBuckets" : 8, 
  "globallyUniqueId" : "h68719E5AC6E7/10443", 
  "doCompact" : true, 
  "waitForSync" : true, 
  "id" : "10443", 
  "isSystem" : false, 
  "journalSize" : 33554432, 
  "isVolatile" : false 
}

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 --data-binary @- --dump - http://localhost:8529/_api/collection/products/properties <<EOF
{ 
  "waitForSync" : true 
}
EOF

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/properties

show response body

Rename collection

renames a collection

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

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.

Example:

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

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products1/rename

{ 
  "code" : 200, 
  "error" : false, 
  "status" : 3, 
  "name" : "newname", 
  "type" : 2, 
  "globallyUniqueId" : "h68719E5AC6E7/10453", 
  "isSystem" : false, 
  "id" : "10453" 
}

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 --data-binary @- --dump - http://localhost:8529/_api/collection/products1/rename <<EOF
{ 
  "name" : "newname" 
}
EOF

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products1/rename

show response body

Rotate journal of a collection

rotates the journal of a collection

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

Path Parameters

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

Rotates the journal of a collection. The current journal of the collection will be closed and made a read-only datafile. The purpose of the rotate method is to make the data in the file available for compaction (compaction is only performed for read-only datafiles, and not for journals).

Saving new data in the collection subsequently will create a new journal file automatically if there is no current journal.

It returns an object with the attributes

  • result: will be true if rotation succeeded

Note: this method is specific for the MMFiles storage engine, and there it is not available in a cluster.

Example:

Rotating the journal:

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/collection/products/rotate <<EOF
{ 
}
EOF

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/rotate

{ 
  "code" : 200, 
  "error" : false, 
  "result" : true 
}

Example:

Rotating if no journal exists:

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/collection/products/rotate <<EOF
{ 
}
EOF

HTTP/1.1 400 Bad Request
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

{ 
  "error" : true, 
  "errorMessage" : "no journal", 
  "code" : 400, 
  "errorNum" : 1105 
}

Return Codes

  • 400: If the collection currently has no journal, HTTP 400 is returned.
  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

Rotating the journal:

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/collection/products/rotate <<EOF
{ 
}
EOF

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
location: /_api/collection/products/rotate

show response body

Rotating if no journal exists:

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/collection/products/rotate <<EOF
{ 
}
EOF

HTTP/1.1 400 Bad Request
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

show response body