I'm trying to create a hash index in ArangoDB via its HTTP API via CURL.
Within my ArangoDB I have several databases like:
As mentioned in the docs in https://docs.arangodb.com/3.11/develop/http/indexes/persistent/ one should call the "Index API" with an URL scheme as follows:
http://localhost:8529/_api/index?collection=products
Applied to my use case I have the following URL:
http://localhost:8529/_api/index?colletion=NodesElectric
Executing the CURL command always returns with an error like:
{
"error": true,
"errorMessage": "collection or view not found",
"code": 404,
"errorNum": 1203
}
I suppose that the problem is caused by having the collection "NodesElectric" in all databases "production", "staging",...
My question is how do I specify the according database for the mentioned collection?
Have not found an hint in the docs herein.
Any operation triggered via ArangoDB's HTTP REST API is executed in the context of exactly one database. To explicitly specify the database in a request, the request URI must contain the database name in front of the actual path:
http://localhost:8529/_db/mydb/... where ... is the actual path to the accessed resource. In the example, the resource will be accessed in the context of the database mydb. Actual URLs in the context of mydb could look like this:
http://localhost:8529/_db/mydb/_api/version
This information can be found in the documentation:
https://docs.arangodb.com/3.11/develop/http/databases/
If no database is specified in the request URL, the _system
database is used by default.
To create a hash index on collection NodesElectric
in your database production
the following URL has to be used:
http://localhost:8529/_db/production/_api/index?collection=NodesElectric