Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

139 lines (82 sloc) 4.097 kB

Elastisch, a Clojure client for Elastic Search

Elastisch is a Clojure client for Elastic Search, a modern distributed RESTful search engine.

Continuous Integration status

Project Goals

  • Closely follow recent Elastic Search releases & features.
  • Be well documented.
  • Be well tested.
  • Be maintained.
  • Integrate with libraries like clojure.data.json and Joda Time.
  • Learn from other clients like the Java and Ruby ones.
  • Target Clojure 1.3.0 and later from the ground up.

Why Not Wrap the Java Client?

Wrapping ES Java client may produce a performance gain but we don't see that to be very useful, and following Java client conventions would likely make Elastish less Clojurish.

Documentation & Examples

We are working on documentation guides & examples site for the 1.0 release. In the meantime, please refer to the test suite for code examples.

Community

Elastisch has a mailing list. Feel free to join it and ask any questions you may have.

To subscribe for announcements of releases, important changes and so on, please follow @ClojureWerkz on Twitter.

This is a Work In Progress

Core Elastisch APIs are stabilized but it is still a work in progress. Keep that in mind. 1.0 will be released in early 2012 together with documentation guides and dedicated website.

Artifacts

With Leiningen:

[clojurewerkz/elastisch "1.0.0-alpha1"]

With Maven:

<dependency>
  <groupId>clojurewerkz</groupId>
  <artifactId>elastisch</artifactId>
  <version>1.0.0-alpha1</version>
</dependency>

If you feel comfortable using snapshots:

With Leiningen:

[clojurewerkz/elastisch "1.0.0-SNAPSHOT"]

With Maven:

<dependency>
  <groupId>clojurewerkz</groupId>
  <artifactId>elastisch</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>

Snapshot artifacts are released to Clojars every few days.

Supported Clojure versions

Elastisch is built from the ground up for Clojure 1.3 and up.

Quickstart

Creating an index with mapping

(let [mapping { :person {
                  :properties {
                  :first-name { :type "string" :store "yes" }
                  :last-name  { :type "string" }
                  :title      { :type "string" :analyzer "snowball" }
                  :biography  { :type "string" :analyzer "snowball"}}}}]
  (elastisch.index/create "people" :mappings mapping))

Storing documents in index

(let [document {:first-name "Jack"
              :last-name  "Black"
              :title      "Sales Manager"
              :biography  "Tries to avoid eating fat, being good to other people and does sports every now and then" }]
  ;; with autogenerated id
  (elastisch.document/create "people" "person" document)

  ;; manually set id
  (elastisch.document/put "people" "person" 152 document))

Querying index

  (elastisch.document/search :query (elastisch.query/term :foo "bar"))

Pitfalls

Right now clj-http's default behavior (to throw exceptions for 40x and 50x responses) is off. Most likely, that will become configurable, throwing exceptions by default, since REST client should behave as close to binary driver as possible and mimic server behavior where possible.

Development

Elastisch uses Leiningen 2. Make sure you have it installed and then run tests against Clojure 1.3.0 and 1.4.0[-beta4] using

lein2 all test

Then create a branch and make your changes on it. Once you are done with your changes and all tests pass, submit a pull request on Github.

License

Copyright (C) 2011-2012 Alex Petrov

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

Jump to Line
Something went wrong with that request. Please try again.