REST client for Elastic Search
Pull request Compare This branch is 47 commits behind mpenet:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/clj_esearch
test/clj_esearch/test
.gitignore
README.md
project.clj

README.md

clj-esearch

Clojure REST client for Elastic Search

Uses Aleph HTTP client under the hood.

The query map corresponds to the JSON query DSL, allowing you to leverage the full features of elastic search Elastic Search Query DSL ref

Usage

(use 'clj-esearch.core)

;; returns a Lamina result channel

(add-doc "http://127.0.0.1:9200"
         "tweets"
         "tweet"
         {:text "foo bar" :author {:name "john"} :posted 123450000000})


(add-doc "http://127.0.0.1:9200"
         "tweets"
         "tweet"
         {:text "foo bar" :author {:name "john"} :posted 123450000000}
         :id 1) ;; specified id


;; If you need the query to block/wait for the response dereference it

@(add-doc ...)

;; Error handling can be done using lamina utilities (same is true for timeouts)

(lamina.core/run-pipeline
  (add-doc "http://127.0.0.1:9200"
           "tweets"
           "tweet"
           {:text "foo bar" :author {:name "john"} :posted 123450000000})
  :error-handler (fn [e] ...)
  #(when (> (:status %) 201) (throw (Exception. "Not good"))))

See tests for more details.

Lamina Result Channel Aleph

Installation

clj-esearch is available as a Maven artifact from Clojars:

:dependencies
  [[clj-esearch "0.4.0"] ...]

License

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