Skip to content

Zero dependency, fetch based tiny elasticsearch client.

Notifications You must be signed in to change notification settings

samuelgja/elastic-tiny-client

Repository files navigation

Elastic search tiny client

Build Code quality check Build Size NPM downloads

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 😎.

About

Zero dependency, fetch based tiny elasticsearch client.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages