ArangoDB v3.13 is under development and not released yet. This documentation is not final and potentially incomplete.
HTTP interface for multi-dimensional indexes
Create a multi-dimensional index
collection-name, if
it does not already exist.estimates boolean (default:
true)This attribute controls whether index selectivity estimates are maintained for the index. Not maintaining index selectivity estimates can have a slightly positive impact on write performance.
The downside of turning off index selectivity estimates is that the query optimizer is not able to determine the usefulness of different competing indexes in AQL queries when there are multiple candidate indexes to choose from.
The
estimatesattribute is optional and defaults totrueif not set. It has no effect on indexes other thanpersistent,mdi, andmdi-prefixed. It cannot be disabled for non-uniquemdiindexes because they have a fixed selectivity estimate of1.storedValues array of strings
The optional
storedValuesattribute can contain an array of paths to additional attributes to store in the index. These additional attributes cannot be used for index lookups or for sorting, but they can be used for projections. This allows an index to fully cover more queries and avoid extra document lookups.You can have the same attributes in
storedValuesandfieldsas the attributes infieldscannot be used for projections, but you can also store additional attributes that are not listed infields. Attributes instoredValuescannot overlap with the attributes specified inprefixFields. There is no reason to store them in the index because you need to specify them in queries in order to usemdi-prefixedindexes.You cannot create multiple multi-dimensional indexes with the same
sparse,unique,fieldsand (formdi-prefixedindexes)prefixFieldsattributes but differentstoredValuessettings. That means the value ofstoredValuesis not considered by index creation calls when checking if an index is already present or needs to be created.In unique indexes, only the index attributes in
fieldsand (formdi-prefixedindexes)prefixFieldsare checked for uniqueness. The index attributes instoredValuesare not checked for their uniqueness.Non-existing attributes are stored as
nullvalues insidestoredValues.The maximum number of attributes in
storedValuesis 32.
Examples
Creating a multi-dimensional index
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=intervals
{
"type": "mdi",
"fields": [
"from",
"to"
],
"fieldValueTypes": "double"
}Show output
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 215
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"estimates" : false,
"fieldValueTypes" : "double",
"fields" : [
"from",
"to"
],
"id" : "intervals/69455",
"isNewlyCreated" : true,
"name" : "idx_1793257748591280129",
"sparse" : false,
"type" : "mdi",
"unique" : false,
"code" : 201,
"error" : false
}Creating a prefixed multi-dimensional index
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=intervals
{
"type": "mdi-prefixed",
"fields": [
"from",
"to"
],
"fieldValueTypes": "double",
"prefixFields": [
"year",
"month"
]
}Show output
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 279
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"estimates" : true,
"fieldValueTypes" : "double",
"fields" : [
"from",
"to"
],
"id" : "intervals/69587",
"isNewlyCreated" : true,
"name" : "idx_1793257748703477761",
"prefixFields" : [
"year",
"month"
],
"selectivityEstimate" : 1,
"sparse" : false,
"type" : "mdi-prefixed",
"unique" : false,
"code" : 201,
"error" : false
}