# e3po

> Module to index and search MongoDB documents using Elasticsearch

Latest version **2.1.2** (published 2018-07-01) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install e3po
pnpm add e3po
yarn add e3po
bun add e3po
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2018-07-01 |
| First published | 2017-02-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 1 |
| Unpacked size | 170.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anatoly Demidovich |
| Maintainers | dab00 |
| Keywords | mongodb, elasticsearch |

## Links

- npm: https://www.npmjs.com/package/e3po
- Repository: https://github.com/dab00/e3po
- Issues: https://github.com/dab00/e3po/issues
- npm.io page: https://npm.io/package/e3po

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^3.1.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 2.1.2 (latest) — 2018-07-01
- 2.1.1 — 2018-05-09
- 2.0.2 — 2018-03-24
- 2.0.1 — 2018-03-05
- 2.0.0 — 2018-02-23
- 1.3.0 — 2017-12-25
- 1.2.2 — 2017-11-05
- 1.2.1 — 2017-08-19
- 1.2.0 — 2017-07-04
- 1.1.2 — 2017-05-31
- 1.1.1 — 2017-04-22
- 1.1.0 — 2017-04-01
- 1.0.0 — 2017-02-19
- 0.0.0 — 2017-02-12

## README

e3po
---

Module to index and search [MongoDB](https://www.mongodb.com/) documents using [Elasticsearch](https://www.elastic.co/products/elasticsearch)

```javascript
require("e3po")
```

**Motivation**: I'd prefer [MongoDB](https://www.mongodb.com/) syntax to [query](https://docs.mongodb.com/manual/reference/operator/query/) and [update](https://docs.mongodb.com/manual/reference/operator/update/) [Elasticsearch](https://www.elastic.co/products/elasticsearch) index

### Query operators

- [comparison operators](https://docs.mongodb.com/manual/reference/operator/query/#comparison)
- [logical operators](https://docs.mongodb.com/manual/reference/operator/query/#logical)
- [$exists](https://docs.mongodb.com/manual/reference/operator/query/exists/#op._S_exists)
- [$all](https://docs.mongodb.com/manual/reference/operator/query/all/#op._S_all)
- [$elemMatch](https://docs.mongodb.com/manual/reference/operator/query/elemMatch/#op._S_elemMatch)
- [$text](https://docs.mongodb.com/manual/reference/operator/query/text/#op._S_text) (with [{ query, operator, minimum_should_match, boost, analyzer }](https://www.elastic.co/guide/en/elasticsearch/guide/current/full-text-search.html))
- [$nearSphere](https://docs.mongodb.com/manual/reference/operator/query/nearSphere/#op._S_nearSphere) (with [point](https://docs.mongodb.com/manual/reference/geojson/#geojson-point) and [$maxDistance](https://docs.mongodb.com/manual/reference/operator/query/maxDistance/#op._S_maxDistance) as [geo_distance](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html))
- [$geoWithin](https://docs.mongodb.com/manual/reference/operator/query/geoWithin/#op._S_geoWithin)(with [polygon](https://docs.mongodb.com/manual/reference/geojson/#polygon) as [geo_polygon](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html))

Query operators use [Elasticsearch bool query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

### Update operators

- [fields operators](https://docs.mongodb.com/manual/reference/operator/update/#fields) (except [$setOnInsert](https://docs.mongodb.com/manual/reference/operator/update/setOnInsert/#up._S_setOnInsert))
- [array operators](https://docs.mongodb.com/manual/reference/operator/update/#array)

[Conditions](https://docs.mongodb.com/manual/reference/operator/update/pull/#remove-all-items-that-match-a-specified-pull-condition) operators available:

  - [comparison operators](https://docs.mongodb.com/manual/reference/operator/query/#comparison)
  - [logical operators](https://docs.mongodb.com/manual/reference/operator/query/#logical)
  - [$exists](https://docs.mongodb.com/manual/reference/operator/query/exists/#op._S_exists)

Update operators use [Elasticsearch painless script](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html)

[Modifiers](https://docs.mongodb.com/manual/reference/operator/update/#modifiers) are supported

[$](https://docs.mongodb.com/manual/reference/operator/update/positional/#up._S_), [$[]](https://docs.mongodb.com/manual/reference/operator/update/positional-all/#up._S_[]) and [$[\<identifier\>]](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/#up._S_[<identifier>]) operators are supported only with [$set](https://docs.mongodb.com/manual/reference/operator/update/set/#up._S_set) operator and without [query selectors](https://docs.mongodb.com/manual/reference/operator/query/#query-selectors)

### Examples

**e3po**

```javascript
const { Client } = require('elasticsearch')
const e3po = require('e3po')({
  client: new Client({ host: '127.0.0.1:9200' }),
  index: 'test',
  type: 'test'
})
```

**e3po.search** - [search](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search) using [Elasticsearch query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)

```javascript
e3po.search({
  query: {},
  sort: { _id: -1 },
  skip: 0,
  limit: 1,
  projection: {}
})
```

**e3po.find** - [search](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search) using [MongoDB query](https://docs.mongodb.com/manual/reference/operator/query/)

```javascript
e3po.find({
  query: {},
  filter: {},
  sort: { _id: -1 },
  skip: 0,
  limit: 1,
  projection: {}
})
```

**e3po.insert** - [create index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-index)

```javascript
e3po.insert({
  body: { a: 1 }
})
```

**e3po.upsert** - [create or update index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-index)

```javascript
e3po.upsert({
  id: '1',
  body: { a: 1 }
})
```

**e3po.update** - [update index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-update)

```javascript
e3po.update({
  id: '1',
  body: { a: 2 }
)
```

**e3po.remove** - [delete index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-indices-delete)

```javascript
e3po.remove({
  id: '1'
})
```

**e3po.updateByScript** - [update index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-update) using [Elasticsearch painless script](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html) and [MongoDB update operators](https://docs.mongodb.com/manual/reference/operator/update/)

```javascript
e3po.updateByScript({
  id: '1',
  body: {
    $set: {
      a: 2
    }
  }
})
```

**e3po.updateByQuery** - [update index by query](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-updatebyquery) using [Elasticsearch painless script](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html), [MongoDB query operators](https://docs.mongodb.com/manual/reference/operator/query/) and [MongoDB update operators](https://docs.mongodb.com/manual/reference/operator/update/)

```javascript
e3po.updateByQuery({
  query: {},
  body: {
    $set: {
      a: 2
    }
  }
)
```

**e3po.removeByQuery** - [delete index by query](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-deletebyquery) using [MongoDB query operators](https://docs.mongodb.com/manual/reference/operator/query/)

```javascript
e3po.removeByQuery({
  query: {}
})
```

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