ES Kotlin - Elasticsearch Query DSL


Elasticsearch Query DSL for Kotlin.

This library aims to minimize the gap between the Elasticsearch JSON query DSL, and the API used when writing kotlin applications. This integrates with the existing java API, only providing a nicer syntax to build the queries.



val query = bool {
    must {
        term { "user" to "kimchy" }
    filter {
        term { "tag" to "tech" }
    must_not {
        range {
            "age" {
                from = 10
                to = 20
    should = listOf(
        term { "tag" to "wow" },
        term { "tag" to "elasticsearch" })
    minimum_should_match = 1
    boost = 1.0f

The library is currently getting occasional updates to track the latest Kotlin and Elasticsearch versions.
Contributions are always welcome!


nice… But it look synchronous…


Yes ESKotlin just adds convenience builder functions to the standard Elasticsearch Java API. It’s one of my favourite uses for kotlin and extension functions - giving a library the API you wish it had without completely wrapping or reimplementing it :slight_smile:

Edit: actually looks like the Elasticsearch 6.3 java api is asynchronous:

All operations are completely asynchronous in nature (either accepts a listener, or returns a future).


ok you just build the query =) then its not a problem :+1: