Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 1.41 KB

README.md

File metadata and controls

61 lines (40 loc) · 1.41 KB

✨ elastic-ts

Build Status Status: Alpha npm npm Powered by TypeScript

A TypeScript module for working with Elasticsearch.

Goals

  • Provide TypeScript types for Elasticsearch queries
  • Provide a typed query body builder with an immutable API

Non-goals

  • Replace the official Elasticsearch API client

Requirements

  • TypeScript 2.8 - this project uses conditional types which were introduced in TypeScript 2.8

Installation

yarn add elastic-ts

Usage

Types

import {SearchBody} from 'elastic-ts'

const body: SearchBody = {
  query: {
    match_all: {},
  },
}

Builder

import {esBuilder} from 'elastic-ts'

const body = esBuilder()
  .query('match_all', {})
  .filter('terms', 'field', ['one', 'two'])
  .build()

Credits

The query builder API is heavily inspired by bodybuilder, although there are subtle API and behavioral differences.

License

The MIT license. See LICENSE.