Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 2 months 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 (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-23T03:52:55.000Z (8 months ago)
- Last Synced: 2024-10-28T13:16:51.292Z (about 2 months ago)
- Topics: bun, client, elasticsearch, nodejs
- Language: TypeScript
- Homepage:
- Size: 292 KB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elastic search tiny client
[![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/actions/workflows/code-check.yml/badge.svg)](https://github.com/samuelgja/elastic-tiny-client/actions/workflows/code-check.yml)
[![Build Size](https://img.shields.io/bundlephobia/minzip/elastic-tiny-client?label=Bundle%20size)](https://bundlephobia.com/result?p=elastic-tiny-client) [![NPM downloads](https://img.shields.io/npm/dm/elastic-tiny-client.svg?style=flat)](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 😎.