elastic-tiny-client
v0.1.4
Published
[![Build](https://github.com/samuelgja/elastic-tiny-client/actions/workflows/build.yml/badge.svg)](https://github.com/samuelgja/elastic-tiny-client/actions/workflows/build.yml) [![Code quality check](https://github.com/samuelgja/elastic-tiny-client/action
Downloads
214
Readme
Elastic search tiny client
Zero dependency, fetch based tiny elasticsearch client.
Also it work's in browser, node.js and bun 🥳 Probably can be also run in deno, but not tested yet.
Why? Because I needed a elasticsearch client for bun but elasticsearch-js still not works 🥺
Install
yarn add elastic-tiny-client // or bun add elastic-tiny-client
Simple usage
import { ElasticClient } from 'elastic-tiny-client'
const client = new ElasticClient({ hosts: ['http://localhost:9200'] })
const indexResult = await client.index({
index: 'my-index',
body: {
title: 'test',
},
})
const result = await client.search({
index: 'my-index',
body: {
query: {
match: {
title: 'test',
},
},
},
})
const deleteResult = await client.delete({
index: 'my-index',
id: indexResult.body._id,
})
Basic api are taken from elasticsearch-rest-api-docs. There are still some parts missing, so PR's are welcome 😎.