0

I'm trying to create a hash index in ArangoDB via its HTTP API via CURL.

Within my ArangoDB I have several databases like:

  • production
  • staging
  • test

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.

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.