May 9, 2016

Finally v1.0.0 of clj-ravendb, a RavenDB client for Clojure.


I've finally found the time to add a few missing features and a sprinkling of love to clj-ravendb and given it a 1.0.0 release. You can find the API docs here


Almost all of the information present in these three articles is still correct, this post will highlight any differences and discuss new features.

What's new

Querying indexes

Raw lucene query

For instances where clj-ravendb offers no built in support for generating a query of a certain type it is now possible to use a raw lucene query.

Range queries

There is now support for inclusive range queries using the following syntax.

Creating indexes

Support for creating indexes has been around since early versions but it has changed since the articles mentioned above were published. Instead of supplying the where clause of an index using a string we can now do the following.

Analyzed fields

As well as the new syntax for creating indexes I've also added the ability to specify anlyzed fields.

Using the :fields key you can now specify various indexing options:

Deleting indexes

This is only a small enhancement but is now possible like so:

OAuth support

There is now also support for OAuth authentication. You can create a client that support OAuth like so:

If you plan on creating a client for the lifetime of your application it is worth keeping in mind that the OAuth token will expire. Internally clj-ravendb will request a new token based on the :oauth-expiry-seconds configuration of the client. For example, a client configured to request a new token after 20 minutes can be created like so:

If an :oauth-expiry-seconds is not supplied then a default of 600 seconds is used.


RavenDB has a number of caching methods in it's official .NET client, clj-ravendb only supports no caching and a minimal version of aggressive caching at the moment.

To use aggressive caching specify the option when creating a client:

When using aggressive caching any request made using load-documents will be cached for the lifetime of the client. Any changes made to documents using put-document! or bulk-operations! will be reflected in the clients local cache. When using replication keep in mind that data can become stale.

Some notes on replication

When configured clj-ravendb will inspect the Raven/Replication/Destinations endpoint and failover to replicas when the primary node is unavailable. It is worth keeping in mind that this initial list of replicas is populated when the client is first created. If you create a client that exists for the lifetime of your application then the list of replicas can become stale.

What's left to do

  • ClojureScript - When I started working on this I had the goal of adding support for ClojureScript. I've got a spike that is almost working, the main pain point left is generating HTTP requests in a consistent fashion.
  • Agressive Caching - Enable aggressive caching for a subset of documents. Usually aggressive caching is suitable for some document types but not others. Add a configuration option to specify how long the aggresive cache is valid for.
  • Replication - The .NET RavenDB client has support for round robin using all replicas. Currently clj-ravendb only has support for reading/writing to a replica node when other nodes have failed.
Tags: clojure clj-ravendb ravendb