An asynchronous ElasticSearch client for Clojure.
Currently under development. Warning: more APIs have been implemented than tested at this stage.
Tested with ElasticSearch 1.6.
This project was intended to complement my asynchronous Redis client, and to contrast my ElasticSearch client for Rust.
The goal is to provide a very lightweight client that doesn't hide or obscure any of the advanced features of ElasticSearch, and to have a direct mapping to the raw APIs so that users familiar with the ElasticSearch APIs will be able to use this client directly.
clj-es.client
contains one function per API. The first parameter is always the "client" (a map containing hostname and/or port, these will default to localhost
and 9200
if not set), the next parameters correspond to the path elements of each ES call. The final (optional) parameter, is the body (e.g. the document or query). For example:
(index es-client "index-name" "doc-type" document)
Will translate as a POST to http://es:9200/index-name/doc-type
with the document as the body.
Other parameters that are sent as query parameters, e.g. routing and version fields, are set using with-params
:
(with-params {:version 5}
(index es-client "index-name" "doc-type" id document))
Many ElasticSearch operations take use queries. These are either in the form of a URI query parameter or in the body (along side other arguments) in the form of the query DSL.
Functions that use queries support both of these options. If a String
is provided, it will be used as a URI search; otherwise it is assumed to be a request body that will contain a query.
Many ElasticSearch operations can be applied to multiple indexes and multiple types. For these operations either a String
, representing a single index/type; or a sequence or vector of String
s, representing multiple indexes/types, can be provided.
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
Please note, this is scheduled to be removed in ElasticSearch 2.0
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
Supports both search by URI: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html, and search by query body: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html.
Because this is a thin layer, anything that can be expressed via a request-body search is supported here - including aggregations and scan/scroll operations.
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
Templates can be got and set using search-template
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-exists.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-more-like-this.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html and https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html
Not yet supported
Not yet supported
A pool of persistent HTTP connections are used, with a default keepalive value of 30 seconds.
TBC: compare with existing clients
- Implementation of Field stats API (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-more-like-this.html)
- Helper functions for scan/scroll
Copyright 2015 Ben Ashford
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.