All Projects → mpenet → Spandex

mpenet / Spandex

Elasticsearch client for Clojure (built on new ES 7.x java client)

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Spandex

Xsql
Unified SQL Analytics Engine Based on SparkSQL
Stars: ✭ 176 (-9.74%)
Mutual labels:  elasticsearch
Mage2vuestorefront
Magento to Vue-storefront datapump - synchronizes Products, Categories and Product-to-category links between your Magento2 API and NoSQL database of vue-storefront
Stars: ✭ 183 (-6.15%)
Mutual labels:  elasticsearch
Elastiflow
Network flow analytics (Netflow, sFlow and IPFIX) with the Elastic Stack
Stars: ✭ 2,322 (+1090.77%)
Mutual labels:  elasticsearch
Elasticsearch
Elasticsearch module based on the official elasticsearch package 🌿
Stars: ✭ 176 (-9.74%)
Mutual labels:  elasticsearch
Mozdef
DEPRECATED - MozDef: Mozilla Enterprise Defense Platform
Stars: ✭ 2,164 (+1009.74%)
Mutual labels:  elasticsearch
Prometheus Es Exporter
Prometheus Elasticsearch Exporter
Stars: ✭ 184 (-5.64%)
Mutual labels:  elasticsearch
Operators
Collection of Kubernetes Operators built with KUDO.
Stars: ✭ 175 (-10.26%)
Mutual labels:  elasticsearch
Snow Owl
🦉 Snow Owl - production ready, scalable terminology server (SNOMED CT, ICD-10, LOINC, dm+d, ATC and others)
Stars: ✭ 191 (-2.05%)
Mutual labels:  elasticsearch
Elasticsearch Full
full-scale introduce for elasticsearch
Stars: ✭ 182 (-6.67%)
Mutual labels:  elasticsearch
Mongo Es
A MongoDB to Elasticsearch connector
Stars: ✭ 185 (-5.13%)
Mutual labels:  elasticsearch
Mirage
🎨 GUI for simplifying Elasticsearch Query DSL
Stars: ✭ 2,143 (+998.97%)
Mutual labels:  elasticsearch
Search Server
⭐️ Our core search API repository
Stars: ✭ 181 (-7.18%)
Mutual labels:  elasticsearch
Wazuh
Wazuh - The Open Source Security Platform
Stars: ✭ 3,154 (+1517.44%)
Mutual labels:  elasticsearch
Es Mode
An Emacs major mode for interacting with Elasticsearch
Stars: ✭ 176 (-9.74%)
Mutual labels:  elasticsearch
Awesome Es
简书的优秀资源可以向专题“elasticsearch”投稿,简书外的资源欢迎向本awesome pull requests
Stars: ✭ 188 (-3.59%)
Mutual labels:  elasticsearch
Docker Elastic Stack
ELK Stack Dockerfile
Stars: ✭ 175 (-10.26%)
Mutual labels:  elasticsearch
Emoji Search
😄 Emoji synonyms to build your own emoji-capable search engine (elasticsearch, solr)
Stars: ✭ 184 (-5.64%)
Mutual labels:  elasticsearch
Firecamp
Serverless Platform for the stateful services
Stars: ✭ 194 (-0.51%)
Mutual labels:  elasticsearch
Elasticsearch Jest Example
ElasticSearch Java Rest Client Examples
Stars: ✭ 189 (-3.08%)
Mutual labels:  elasticsearch
Mahuta
IPFS Storage service with search capability
Stars: ✭ 185 (-5.13%)
Mutual labels:  elasticsearch

spandex

Elasticsearch new low level rest-client wrapper

Why?

To quote "State of the official Elasticsearch Java clients"

The Java REST client is the future for Java users of Elasticsearch.

Because the legacy native client is a bit of a nightmare to deal with (for many reasons) and the new REST client is quite capable and fast too, see "Benchmarking REST client and transport client"

Not to mention it supports some interesting features:

  • compatibility with any Elasticsearch version

  • load balancing across all available nodes

  • failover in case of node failures and upon specific response codes

  • failed connection penalization

  • persistent connections

  • trace logging of requests and responses

  • optional automatic discovery of cluster nodes (also known as sniffing)

Goals

  • Be minimal & performant

  • RING inspired

  • All "exotic" features should be optional

  • Not a giant DSL over another DSL, just maps everywhere. Read ElasticSearch doc -> done, not another layer of indirection

  • Provide minimal (and optional) utils to do the boring stuff (bulk, scroll queries, compose urls)

  • Can do async via simple callbacks based api or core.async

  • Provide specs

Setup

(require '[qbits.spandex :as s])

(def c (s/client {:hosts ["http://127.0.0.1:9200" "https://foo2:3838"]}))

;; add optional sniffer
(def s (s/sniffer c {... options ...}))

Constructing URLs

Most of spandex request functions take a request map as parameter. The :url key differs a bit from the original RING spec, it allows to pass a raw string but also a sequence (potentially 2d) of encodable things, keywords, .toString'able objects that make sense or nil (which could be caused by a missing :url key).

(s/request c {:url [:foo :bar :_search] ...})
(s/request c {:url [:foo [:bar :something "more"] :_search] ...})
(s/request c {:url :_search ...})
(s/request c {:url "/index/_search" ...})
(s/request c {:url (java.util.UUID/randomUUID) ...})
(s/request c {...}) ;; defaults to "/"

Blocking requests

(s/request c {:url [:entries :entry :_search]
              :method :get
              :body {:query {:match_all {}}}})

>> {:body {:_index "entries", :_type "entry", :_id "AVkDDJvdkd2OsNWu4oYk", :_version 1, :_shards {:total 2, :successful 1, :failed 0}, :created true}, :status 201, :headers {"Content-Type" "application/json; charset=UTF-8", "Content-Length" "141"}, :host #object[org.apache.http.HttpHost 0x62b90fad "http://127.0.0.1:9200"]}

Async requests (callbacks)

(s/request-async c {:url "/urls/url/"
                    :method :get
                    :body {:query {:match {:message "this is a test"}}}
                    :success (fn [response-as-clj] ... )
                    :error (fn [ex] :boom)})

Async requests: core.async/promise-chan

(async/<!! (s/request-chan c {:url "/urls/url/"
                              :method :get
                              :body {:query {:match {:message "this is a test"}}}}))

Scrolling

Scrolling via core.async (fully NIO internally), interruptible if you async/close! the returned chan.

(async/go
  (let [ch (s/scroll-chan client {:url "/foo/_search" :body {:query {:match_all {}}}})]
    (loop []
      (when-let [page (async/<! ch)]
        (do-something-with-page page)
        (recur)))))

Bulk requests scheduling

"Faux streaming" of _bulk requests (flushes bulk request after configurable interval or threshold. Uses request-chan internally, so it's quite cheap.

(let [{:keys [input-ch output-ch]} (bulk-chan client {:flush-threshold 100
                                                      :flush-interval 5000
                                                      :max-concurrent-requests 3})]
  ;; happily takes a sequence of actions or single fragments
  (async/put! input-ch [{:delete {:_index "foo" :_id "1234"}} {:_index :bar} {:create {...}}])
  (async/put! input-ch {"delete" {"_index" "website" "_type" "blog" "_id" "123"}}))

;; setup an response consumer (we just want to make sure we don't clog this channel)
(future (loop [] (async/<!! (:output-ch c))))

Installation

Clojars Project

API Docs

cljdoc badge

Or the clj.specs if that's your thing:

Patreon

If you wish to support the work on this project you can do this via my patreon page.

License

Copyright © 2018 Max Penet

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].