Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Clojure client for the ElasticSearch Java API
Clojure JavaScript
branch: 0.2

This branch is 77 commits behind ngrunwald:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


A clojure wrapper around the native Java Elasticsearch API. It aims to be as idiomatic as possible while remaining fast.

The API docs are available here.


For the most basic use case:

(use 'clj-elasticsearch)

(def es (make-client :transport {:hosts ["localhost:9300"] :cluster-name "elasticsearch"}))

(def index-res (index-doc es {:index "test" :type "test"
                         :source (build-doc {:field1 "foo" :field2 42})}))
(def nb-docs (:count (count-docs {:indices ["test"]})))
(def match-all "{\"query\":{\"query_string\":{\"query\":\"*:*\"}}}")
(def res (get-in (search es {:indices ["test"] :types ["test"] :extra-source match-all}) [:hits :hits]))

Vectors and hashes are converted to arrays. See the doc strings for the arguments used by each method and the javadocs for more details about their use. A convert function can be used to try to translate the returned objects to Clojure or other formats. It can be sprecified by the :format key when calling the various API methods.

You can also use the functions asynchronously by providing a callback listener with the :listener key, as such:

(count-docs es {:indices ["test"]
                :listener (make-listener
                              {:on-failure (fn [e] (throw e))
                               :on-success (fn [res] (println (convert res :clj)))})})

A bit more details can be found in the tests.

See Also

For other Elasticsearch Clojure clients:

  • elastisch: An idiomatic Clojure wrapper for the Http API
  • esearch: An asynchronous client for the Http API


Copyright (C) 2012 Linkfluence

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.