Hello Search

adamfowleruk edited this page Jan 20, 2016 · 3 revisions

Back to Home

This tutorial will get you started with a Node.js application against a MarkLogic V6+ default install very quickly

Pre-requisites

  • MarkLogic V6+ installed with admin account user/pass as admin/admin
  • Node.js V0.8+ installed

Installation

Use NPM to install MLJS:-

npm install mljs

Basic use to save a document, then fetch it again:-

Create a file called hellosearch.js with the following content:-

  var mljs = require("mljs");
  var db = new mljs(); // default options
  db.save({from: "test", to: "all", body: "wibble"},"/messages/1", {collection: "messages"},function(result) {
    // now fetch it
    db.get("/messages/1", function(result) {
      // now print it
      console.log("Doc content: " + JSON.stringify(result.doc));
      // now delete it
      db.delete("/messages/1", function(result) {
        console.log("Doc deleted");
      });
    });
  });

Now execute this with:-

node hellosearch.js

You should see the output produced.

Where now?

For a comprehensive list of samples, visit the Node.js test scripts here: https://github.com/adamfowleruk/mljs/tree/master/test

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.