MLJS search context improvements…

I’ve rejigged a few things in MLJS. Should make writing apps on MarkLogic even easier. Read on for more details…


As I’ve already mentioned I’ve renamed MLDB to MLJS to better reflect what it is for. This is now everywhere in the code base, documentation, builds and references.

Search Context

Previously the widget executing the search was responsible for calling MLJS core and managing search options. This was cumbersome, and you could easily see duplicate code emerging when I eventually create more complex search widgets. E.g. an advanced search. Also NodeJS users of MLJS core were missing out on the search event publish/subscribe model.

I’ve now created an mljs.prototype.searchcontext object. Simply create on of these (E.g. from ‘new mydb.searchcontext()’ ) and call it’s register function for each widget/class. This function introspects the JavaScript object to find functions that match the best practice templates. E.g. an updateResults function would be registered with the search context’s resultsPublisher event subscribe function.

This makes my widget code much cleaner, and provides this functionality to NodeJS application developers too. I will extend this eventually for all search modification functionality. This means you won’t need to invoke the structured query builder directly, or parse your own default search grammar string. You just call search context methods and it will handle all the updates for you.

Query parsing

The previous searchbar widget did not handle facets with spaces correctly. An example would be author:”John Smith” which is perfectly valid. This is now fixed. There was also an unnoticed parser bug that would have caused anyone using MLDB for the last few weeks to hit an issue when using the searchbar widget. This is now resolved.

MLJS example Roxy Hybrid project

I hadn’t realised but the default URL and indeed default ‘mldbtest’ controller URL in this Roxy sample application gave a failed error. I’ve now directed the default / route to the main search page and a list of sample function pages.

Other improvements

I’ve also in the last 60 days added support for some custom DLS endpoints I wrote, and added semantic widgets and functionality. The semantic capabilities of V7 EA 1 & 2 are supported. I’ve also built a nice interactive SPARQL query builder to ease searching the triple store. I’ve also created a Markings widget that allows extraction of facts and saving of these to the triple store, whilst maintaining links back to the original content. This is likely to be a common application pattern in V7.

Coming soon

I’ve nearly completed my belated June release, version 0.8. Things left to finish are facet More… and All… links, and fixing the Sort drop down box. Currently it’s just for show. I’ll also add a better default XML renderer and fully test text, json and XML snippeting display in the results widget.

I also want to add better documentation around the XML support where applicable, and document creating a custom renderer more. I’ll also update all demos to include an error widget so you don’t need FireBug to find out what has gone wrong!

I need to run through the Mocha NodeJS mode tests and provide a sample application too. This will probably be the Instant Messaging integration app I have developed. Great alerting example.


There’s been a lot of tidying up done that should allow developers to more easily get up to speed with MLJS quicker, and have a more reliable application experience, with even higher performance than in previous versions. Let me know what updates you’re interested in and I’ll prioritise them.

You can grab the latest MLJS from GitHub as usual.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s