# roadiejs-elastic

> Elasticsearch capabilities in RoadieJS

Latest version **0.0.7** (published 2015-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install roadiejs-elastic
pnpm add roadiejs-elastic
yarn add roadiejs-elastic
bun add roadiejs-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.0.7 |
| Published | 2015-08-25 |
| First published | 2015-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| Author | Tim Needham |
| Maintainers | timneedham |
| Keywords | roadieJS, elastic, search |

## Links

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

## Dependencies (4)

- [async](https://npm.io/package/async.md) ~0.9.0
- [dottie](https://npm.io/package/dottie.md) ^0.2.4
- [underscore](https://npm.io/package/underscore.md) ~1.5.2
- [elasticsearch](https://npm.io/package/elasticsearch.md) ^4.0.2

## 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

- 0.0.7 (latest) — 2015-08-25
- 0.0.6 — 2015-07-22
- 0.0.5 — 2015-06-18
- 0.0.4 — 2015-04-25
- 0.0.3 — 2015-02-07
- 0.0.2 — 2015-02-07
- 0.0.1 — 2015-02-06

## README

# roadiejs-elastic
##### A plugin for [RoadieJS](https://github.com/wmfs/roadiejs)

Integrates RoadieJS with Elasticsearch's search, complete and aggregation capabilities.

## Contents
* [API](#api)
  * [searchAll (GET)](#searchAllGet)
  * [searchAll (POST)](#searchAllPost)
  * [searchIndex (GET)](#searchIndexGet)
  * [searchIndex (POST)](#searchIndexPost)
  * [findById](#findById)
  * [complete](#complete)
* [Activities](#activities)
  * [populateLookups](#populateLookups)
* [Data tasks](#dataTasks)
  * [elasticDocSync](#elasticDocSync)
  * [elasticPurge](#elasticPurge)
* [License](#license)

## <a name="api"></a>API

### <a name="searchAllGet"></a>searchAll (GET)

Searches all RoadieJS indexes using parameters supplied in the request.

###### Request
<code><strong>GET</strong></code> <code>/search</code>

**Example**
`http://localhost:3010/search?q=Walter&from=11&size=10&category=admin`

**Query parameters**

| Parameter | Notes
| ----- | ----
| `q`  | Query string to filter results. Supports Elasticsearch's [query_string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) syntax.
| `from`  | Zero-indexed offset for use when paginating results
| `size`  | Maximum number of documents returned
| `sort`  | Use to sort results. Some options: Give just a field name, and documents will be ordered by that field, ascending. Suffix with a `:desc` to make the order descending. Also supports comma delimitation for multi-field sorts.
| `refresh`  | Either `true` or `false` (the default). If `refresh` is `true` the index will be refreshed (e.g. wait until all outstanding document changes are resolved) before attempting the search. Useful if results are required instantly after a document has been updated.
| `category`  | Restrict the search to within the specified category
| `subCategory`  | Restrict the search to within the specified sub-category

###### Response

**Status** ```200```

* The body of the response mirrors that of the results from the underlying Elasticsearch query.

***

### <a name="searchAllPost"></a>searchAll (POST)

Searches all RoadieJS indexes, like `searchAll (GET)`. except Elasticsearch [DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) should be provided in the request body.

###### Request
<code><strong>POST</strong></code> <code>/search</code>

```
{
  refresh: true,
  query: {
    range: {
      "squareMiles": {
        "gt": 150000
      }
    }
  }
}
```

* The body of the request should be valid Elasticsearch [DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html).


###### Response

**Status** ```200```

* The body of the response mirrors that of the results from the underlying Elasticsearch query.

***


### <a name="searchIndexGet"></a>searchIndex (GET)

Searches the specified index, using parameters supplied in the request.

###### Request
<code><strong>GET</strong></code> <code>/search/:indexName</code>

| Parameter | Notes
| ----- | ----
| `indexName`  | The name of a valid Elasticsearch index (without the `roadiejs.` prefix)

**Query parameters**

| Parameter | Notes
| ----- | ----
| `q`  | Query string to filter results. Supports Elasticsearch's [query_string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) syntax.
| `from`  | Zero-indexed offset for use when paginating results
| `size`  | Maximum number of documents returned
| `sort`  | Use to sort results. Some options: Give just a field name, and documents will be ordered by that field, ascending. Suffix with a `:desc` to make the order descending. Also supports comma delimitation for multi-field sorts.
| `refresh`  | Either `true` or `false` (the default). If `refresh` is `true` the index will be refreshed (e.g. wait until all outstanding document changes are resolved) before attempting the search. Useful if results are required instantly after a document has been updated.
| `category`  | Restrict the search to within the specified category
| `subCategory`  | Restrict the search to within the specified sub-category

###### Response

**Status** ```200```

* The body of the response mirrors that of the results from the underlying Elasticsearch query.

***

### <a name="searchIndexPost"></a>searchIndex (POST)

Searches the specified index, like `searchIndex (GET)`. except Elasticsearch [DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) should be provided in the request body.

###### Request
<code><strong>POST</strong></code> <code>/search/:indexName</code>

| Parameter | Notes
| ----- | ----
| `indexName`  | The name of a valid Elasticsearch index (without the `roadiejs.` prefix)


```
{
  refresh: true,
  query: {
    range: {
      "squareMiles": {
        "gt": 150000
      }
    }
  }
}
```

* The body of the request should be valid Elasticsearch [DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html).

###### Response

**Status** ```200```

* The body of the response mirrors that of the results from the underlying Elasticsearch query.

***

### <a name="findById"></a>findById

Returns a document with the matching `id`, from the specified index.

###### Request
<code><strong>GET</strong></code> <code>/search/:indexName/:id</code>

| Parameter | Notes
| ----- | ----
| `indexName`  | The name of a valid Elasticsearch index (without the `roadiejs.` prefix)
| `id`  | The `id` of an Elasticsearch document

###### Response

**Status** ```200```

* The body of the response mirrors that of the results from the underlying Elasticsearch query.

***

### <a name="complete"></a>complete

Delivers typeahead functionality based on Elasticsearch's [Completion Suggester](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)

###### Request
<code><strong>GET</strong></code> <code>/complete/:indexName</code>

| Parameter | Notes
| ----- | ----
| `indexName`  | The name of a valid Elasticsearch index (without the `roadiejs.` prefix)

**Query parameters**

| Parameter | Notes
| ----- | ----
| `text`  | The as-you-type text from which will be sent to Elasticsearch's [Completion Suggester](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html).


###### Response

**Status** ```200```

* The body of the response mirrors that of the results from Elasticsearch's [Completion Suggester](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html).


## <a name="activities"></a>Activities

### <a name="populateLookups"></a>populateLookups
Used to derive a user-facing label from a Elasticsearch document, based on a stored `id` value.
###### Example
```json
{
  "element": "activity",
  "id": "populateLookups",
  "path": "maintainTeacher",
  "config": {
    "activityType": "populateLookups",
    "config": {
      "targetActivityId": "showTeacherUi",
      "lookups": [
        {
          "field": "department",
          "schema": "departments"
        }
      ]
    }
  }
}
```
###### Config

| Name        | Type   | Notes
| ------------ | -------| -----------
| `targetActivityId`  | `string` | The `id` of an activity within the current flow, that is storing the `id` value to lookup in Elasticsearch.
| `field`| `string` | Identifies which field stores the `id` value in the target activities `data` object.
| `schema`| `string` | The 'child' schema defined in the blueprint, which should contain the `id` identified by `field`


## <a name="dataTasks"></a>Data tasks

### <a name="elasticDocSync"></a>elasticDocSync
Used to synchronise create/update/delete operations on schema documents with their counterparts in an Elasticsearch index.

* There's no need to define this task explicitly, it's added automatically as part of the `schema` element initialisation.

---

### <a name="elasticPurge"></a>elasticPurge
Used to synchronise purges of schemas with the removal of documents in the associated Elasticsearch index.

* There's no need to define this task explicitly, it's added automatically as part of the `schema` element initialisation.


## <a name="license"></a>License
[MIT](https://github.com/wmfs/roadiejs-elastic/blob/master/LICENSE.md)

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