# es-bulk-update-builder

> Bulk update request body builder for Elasticsearch

Latest version **1.0.0** (published 2018-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install es-bulk-update-builder
pnpm add es-bulk-update-builder
yarn add es-bulk-update-builder
bun add es-bulk-update-builder
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-11 |
| First published | 2016-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.3 |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Johns |
| Maintainers | middleengine |
| Keywords | elasticsearch, bulk, update |

## Links

- npm: https://www.npmjs.com/package/es-bulk-update-builder
- Repository: https://github.com/stevejay/es-bulk-update-builder
- Homepage: https://github.com/stevejay/es-bulk-update-builder#readme
- Issues: https://github.com/stevejay/es-bulk-update-builder/issues
- npm.io page: https://npm.io/package/es-bulk-update-builder

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-06-11
- 0.2.2 — 2018-05-26
- 0.2.1 — 2018-05-26
- 0.2.0 — 2018-05-26
- 0.1.3 — 2018-05-26
- 0.1.2 — 2016-12-29
- 0.1.1 — 2016-12-22
- 0.1.0 — 2016-12-21

## README

# es-bulk-update-builder

Bulk update request body builder for Elasticsearch

[![npm version](https://badge.fury.io/js/es-bulk-update-builder.svg)](https://badge.fury.io/js/es-bulk-update-builder)
[![Codeship Status for stevejay/es-bulk-update-builder](https://app.codeship.com/projects/6cc5dcf0-aa06-0134-4024-3e211d17d664/status?branch=master)](https://app.codeship.com/projects/191800)
[![Coverage Status](https://coveralls.io/repos/github/stevejay/es-bulk-update-builder/badge.svg?branch=master)](https://coveralls.io/github/stevejay/es-bulk-update-builder?branch=master)
![license](https://img.shields.io/npm/l/es-bulk-update-builder.svg)

[![NPM](https://nodei.co/npm/es-bulk-update-builder.png)](https://nodei.co/npm/es-bulk-update-builder/)

## Install

```
$ npm install --save es-bulk-update-builder
```

## Usage

Usage is basically as follows:

```js
const BulkUpdateBuilder = require('es-bulk-update-builder');

const body = new BulkUpdateBuilder()
    .index({ name: 'my-doc' }, 'some-index', 'some-type', 'some-id', 3)
    .update({ name: 'other-doc' }, 'other-index', 'other-type', 'other-id', 4)
    .delete('another-index', 'another-type', 'another-id', 5)
    .build();

// The body variable can now be passed to the JavaScript elasticsearch client, e.g.:
// client.bulk({ body: body });
```

The `index` method is for adding a document, the `update` method is for updating a document, and the `delete` method is for deleting a document.

For each action you can specify a version number, for example `3` in the following example:

```js
const body = new BulkUpdateBuilder()
    .index({ name: 'my-doc' }, 'some-index', 'some-type', 'some-id', 3);
```

If you do specify a version, the [version type](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#_version_types) is set to `external`. You can override that by specifying the desired version type, which in the following example is `external_gte`:

```js
const body = new BulkUpdateBuilder()
    .index({ name: 'my-doc' }, 'some-index', 'some-type', 'some-id', 3, 'external_gte');
```

To specify no versioning information, simply omit it:

```js
const body = new BulkUpdateBuilder()
    .index({ name: 'my-doc' }, 'some-index', 'some-type', 'some-id');
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/es-bulk-update-builder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
