# @idio/elastic

> A Library To Manage Operations On ElasticSearch.

Latest version **0.2.0** (published 2018-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @idio/elastic
pnpm add @idio/elastic
yarn add @idio/elastic
bun add @idio/elastic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-11-15 |
| First published | 2018-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Anton |
| Maintainers | zvr |
| Keywords | elastic, idio |

## Links

- npm: https://www.npmjs.com/package/@idio/elastic
- Repository: https://github.com/idiocc/elastic
- Homepage: https://github.com/idiocc/elastic#readme
- Issues: https://github.com/idiocc/elastic/issues
- npm.io page: https://npm.io/package/@idio/elastic

## Dependencies (2)

- [erotic](https://npm.io/package/erotic.md) 2.0.1
- [elasticsearch](https://npm.io/package/elasticsearch.md) 15.2.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2018-11-15
- 0.1.0 — 2018-11-15

## README

# @idio/elastic

[![npm version](https://badge.fury.io/js/%40idio%2Felastic.svg)](https://npmjs.org/package/@idio/elastic)

`@idio/elastic` Is A Library To Manage Operations On ElasticSearch.

```sh
yarn add -E @idio/elastic
```

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`async search(client: Client, searchParams: SearchParams, queryParams?: Object): Hits[]`](#async-searchclient-clientsearchparams-searchparamsqueryparams-object-hits)
  * [`Hit`](#type-hit)
- [Copyright](#copyright)

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/0.svg?sanitize=true"></a></p>

## API

The package is available by importing its components functions:

```js
import { search } from '@idio/elastic'
```

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/1.svg?sanitize=true"></a></p>

## `async search(`<br/>&nbsp;&nbsp;`client: Client,`<br/>&nbsp;&nbsp;`searchParams: SearchParams,`<br/>&nbsp;&nbsp;`queryParams?: Object,`<br/>`): Hits[]`

The wrapper around search to make a query based on a data object. Returns an empty array no no hits are found.

`import('elasticsearch').Client` __<a name="type-client">`Client`</a>__

`import('elasticsearch').SearchParams` __<a name="type-searchparams">`SearchParams`</a>__

__<a name="type-hit">`Hit`</a>__

|      Name       |     Type      |               Description                |
| --------------- | ------------- | ---------------------------------------- |
| ___id*__        | _string_      | `DQn4JC6q5zZQsgv5KNhiWlgd`               |
| ___index*__     | _string_      | `idio-example`                           |
| ___score*__     | _number_      | `1`                                      |
| ___source*__    | _*_           | `Object {name: "example", user: "idio"}` |
| ___type*__      | _string_      | `doc`                                    |
| _version        | _number_      |                                          |
| _explanation    | _Explanation_ |                                          |
| fields          | _*_           |                                          |
| highlight       | _*_           |                                          |
| inner_hits      | _*_           |                                          |
| matched_queries | _string[]_    |                                          |
| sort            | _string[]_    |                                          |

```js
const INDEX = 'idio-example'

;(async () => {
  // 1. Create a record in ElasticSearch for the example.
  const { id, client } = await getClient()
  const res = await search(client, {
    index: INDEX,
    type: 'doc',
  }, { _id: id })
  console.log(res)
})()
```
```
[ { _index: 'idio-example',
    _type: 'doc',
    _id: '7Tn79YCXy9lKoxQi7l9k0SHq',
    _score: 1,
    _source: 
     { name: 'example',
       user: 'idio',
       date: '2018-11-15T15:57:52.031Z' } } ]
```

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/2.svg?sanitize=true"></a></p>

## Copyright

(c) [Idio][1] 2018

[1]: https://idio.cc

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/-1.svg?sanitize=true"></a></p>

---
_Source: https://npm.io/package/@idio/elastic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
