https://github.com/samuelgja/elastic-tiny-client
Zero dependency, fetch based tiny elasticsearch client.
https://github.com/samuelgja/elastic-tiny-client
bun client elasticsearch nodejs
Last synced: about 1 year ago
JSON representation
Zero dependency, fetch based tiny elasticsearch client.
- Host: GitHub
- URL: https://github.com/samuelgja/elastic-tiny-client
- Owner: samuelgja
- Created: 2023-03-25T20:11:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-17T19:03:33.000Z (over 1 year ago)
- Last Synced: 2025-04-14T03:08:44.052Z (about 1 year ago)
- Topics: bun, client, elasticsearch, nodejs
- Language: TypeScript
- Homepage:
- Size: 299 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elastic search tiny client
[](https://github.com/samuelgja/elastic-tiny-client/actions/workflows/build.yml) [](https://github.com/samuelgja/elastic-tiny-client/actions/workflows/code-check.yml)
[](https://bundlephobia.com/result?p=elastic-tiny-client) [](https://www.npmjs.com/package/elastic-tiny-client)
Zero dependency, fetch based tiny elasticsearch client.
Also it work's in browser, [node.js](http://nodejs.org/) and [bun](https://bun.sh/) 🥳
Probably can be also run in [deno](https://deno.land/), but not tested yet.
Why? Because I needed a elasticsearch client for [bun](https://bun.sh/) but [elasticsearch-js](https://github.com/elastic/elasticsearch-js) still not works 🥺
### Install
```bash
yarn add elastic-tiny-client // or bun add elastic-tiny-client
```
### Simple usage
```ts
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](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html).
There are still some parts missing, so PR's are welcome 😎.