Multi platform kotlin client for Elasticsearch & Opensearch with easily extendable Kotlin DSLs for queries, mappings, bulk, and more.
Project maintained by jillesvangurp
Hosted on GitHub Pages — Theme by mattgraham
KT Search Manual
Kt-search is a Kotlin Multi Platform library to search across the Opensearch and Elasticsearch ecosystem on any platform that kotlin can compile to. It provides Kotlin DSLs for querying, defining mappings, bulk indexing, index templates, index life cycle management, index aliases, and much more. The key goal for this library is to provide a best in class developer experience for using Elasticsearch and Opensearch.
Table of contents
What is Kt-Search
Indices, Settings, Mappings, and Aliases
Search and Queries
Term Level Queries
Geo Spatial Queries
Deep Paging Using search_after and scroll
Indices and Documents
Deleting by query
Efficiently Ingest Content Using Bulk Indexing
Creating Data Streams
Extending the Json DSLs
Using Kotlin Scripting
Migrating from the old Es Kotlin Client
About this Manual
This manual documents how to use the kotlin search client and all of its features. As a manual like this contains a lot of code samples, I ended up writing a mini framework to allow me to generate markdown from Kotlin.
The project for this is called Kotlin4Example. Most of the documentation you will find here has correct code samples that get tested and compiled whenever this project is built and whenever something gets refactored that would affect one of the code samples.
There are several libraries that build on kt-search:
- kt-search-kts - this library combines
kotlinx-cli to make scripting really easy. Combined with the out of the box support for managing snapshots, creating template mappings, bulk indexing, data-streams, etc. this is the perfect companion to script all your index operations. Additionally, it’s a great tool to e.g. query your data, or build some health checks against your production indices.
- kt-search-logback-appender - this is a logback appender that bulk indexes log events straight to elasticsearch. We use this at FORMATION.
- full stack Kotlin demo project A demo project that uses kt-search.
- es-kotlin-client - version 1 of this client; now no longer maintained.
Additionally, I also maintain a few other search related projects that you might find interesting.
- Rankquest Studio - A user friendly tool that requires no installation process that helps you build and run test cases to measure search relevance for your search products. Rankquest Studio of course uses kt-search but it is also able to talk directly to your API and is designed to work with any kind of search api or product that is able to return lists of results.
- querylight - Sometimes Elasticsearch is just overkill. Query light is a tiny in memory search engine that you can embed in your kotlin browser, server, or mobile applications. We use it at FORMATION to support e.g. in app icon search. Querylight comes with its own analyzers and query language.