home shape

Bulk Document Lookups: Efficient Data Retrieval with ArangoDB

ArangoDB 2.6 comes with a specialized API for bulk document lookups. The new API allows fetching multiple documents from the server using a single request, making bulk document retrieval more efficient than when using one request per document to fetch.

Provided the documents keys are known, all the client application needs to do is to call the collection’s lookupByKeys method:

// list of document keys
var keys = [ "foo", "bar", "baz", ...];
var results = db.test.lookupByKeys(keys);
// now all documents are contained in variable 'results'

Additionally, the server-side REST API method for bulk document lookups can be invoked directly via HTTP as follows:

curl                                                  \
  -X PUT                                              \
  http://127.0.0.1:8529/_api/simple/lookup-by-keys    \
  --data '{"collection":"test","keys":["foo","bar","baz"]}'

Jan compared the functionality with single document requests in his latest blog post.

Ingo

Ingo Friepoertner

Ingo is dealing with all the good ideas from the ArangoDB community, customers and industry experts to improve the value provided by the company’s native multi-model approach. In former positions he worked as a product owner and tech consultant, building custom software solutions for large companies in various industries. Ingo holds a diploma in business informatics from FHDW University of Applied Sciences.

3 Comments

  1. CoDEmanX on May 8, 2015 at 11:39 am

    Have you considered the following API?
    db.test.documents(…)
    http://server:port/_api/documents

    Seems more in line with https://docs.arangodb.com/Documents/DocumentMethods.html#document

  2. jsteemann on May 8, 2015 at 4:17 pm

    Thanks for the suggestion. db.test.documents(…) makes perfect sense. I need to check whether the HTTP endpoint URL can also be changed easily.

  3. CoDEmanX on May 8, 2015 at 5:54 pm

    I spotted a difference between document(…) and a possible documents(…) reading your blog post: the latter would accept document keys only, the other keys as well as ids.

    Perhaps documents(…) could be improved to ignore the collection-part of ids and use the document key only, to keep both as similar as possible? (ids from collections other than the one specified in the bulk request should be completely ignored I guess)

Leave a Comment





Get the latest tutorials, blog posts and news: