PCS JS Immersion

Orchestrate with Queries

Using Orchestrate for search

Orchestrate is more than just a key-value store: it supports full-text search! You can do text searches on the command line with grep and the like, of course, but it gets slow as the amount of text grows. Indexed full-text searches (Orchestrate uses Lucene) are much faster.

Using the Orchestrate API for search looks a lot like simple query lookups. For example, to find all your users who're from the good Portland:

db.search('users', 'value.hometown: "Portland" AND NOT "ME"')
.then(function (result) {
  console.log(result.body);
})
.fail(function (err) {});

Exercise: Orchestrate full-text search

Grab the contents of Pride And Prejudice and load them into an Orchestrate database. Use Orchestrate's full-text search to answer these questions:

  • Mr. Bennet suggests Mrs. Bennet speaks so much of her nerves that they're his "old friends." How often does she really mention them?
  • Are there any chapters where Mary appears, but not Lydia? Vice-versa?
  • Which chapters mention Catherine "Kitty" Bennet (not to be confused with Catherine de Bourgh)?