ES Kotlin - Elasticsearch Query DSL


#1

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.

Github
Bintray

Example:

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!


#2

nice… But it look synchronous…


#3

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).

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-api.html


#4

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