Skip to content

Commit

Permalink
Merge pull request #72 from ncb000gt/v0.8.0
Browse files Browse the repository at this point in the history
V0.8.0
  • Loading branch information
brozeph committed Jun 24, 2021
2 parents c554e71 + 2f45dff commit 5e7ea5a
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 558 deletions.
23 changes: 23 additions & 0 deletions HISTORY.md
@@ -1,3 +1,26 @@
# v0.8.0 / 2021-06-23

* Adjustments to support Elasticsearch v7 and up (<https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html>)
* Updated core.add (core.index): added `/_doc` to path and eliminated `_type` parameter requirement
* Updated core.delete: added `/_doc` to path
* Updated core.get: added `/_doc` to path and eliminated `_type` parameter requirement
* Removed core.moreLikeThis: is now accomplished via search query (<https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-mlt-query.html>)
* Updated core.multiGet: removed `_type` from path and eliminated `_type` parameter requirement
* Updated core.update: removed `_type` from path and eliminated `_type` parameter requirement
* Updated core.bulkIndex: removed `_type` from payload interpolation
* Updated core.explain: removed `_type` from path and eliminated `_type` parameter requirement
* Updated core.search: removed `_type` from path
* Updated core.suggest: removed `_type` from path
* Updated core.count: removed `_type` from path
* Updated core.multiSearch: removed `_type` from path
* Updated core.deleteByQuery: removed `_type` from path
* Removed core.exists: fully deprecated in ES 7.x
* Updated indices.putMapping: removed `/_mapping/_type` from resource and eliminated `_type` parameter requirement
* Updated indices.stats: removed `_type` from path
* Updated indices.deleteMapping: removed `_type` from path and elimited `_type` parameter requirement
* Updated indices.exists: removed `_type` from path
* Updated indices.mappings: removed `_type` from path

# v0.7.4 / 2021-06-22

* Updated dependencies
Expand Down
56 changes: 27 additions & 29 deletions README.md
Expand Up @@ -12,6 +12,10 @@ NOTE: `node-es` `v0.6` and newer work with ElasticSearch 5 and up. For older ve
npm install es
```

### Elasticsearch Version Compatibility

When working with Elasticsearch v7.x and up, use `v0.8.x` (latest `npm install es`). When using previous versions of Elasticsearch, please use `v0.7.4` of this module (`npm install es@v0.7.4`).

## Usage

```Javascript
Expand All @@ -34,7 +38,6 @@ es.search({
});
```


## API

Unless otherwise stated, all callback signatures are `function (err, data)`, with `data` being the parsed JSON response from elasticsearch.
Expand All @@ -51,25 +54,23 @@ var

##### config._index

When initializing the library, you may choose to specify an index and/or type to work with at the start to save from having to supply this information in the options for each operation request:
When initializing the library, you may choose to specify an index to work with at the start to save from having to supply this information in the options for each operation request:

```Javascript
var config = {
_index : 'pet',
_type : 'kitteh'
_index : 'pet'
};
```

Additionally, if working with multiple indexes or types, you may specify them as arrays:
Additionally, if working with multiple indexes, you may specify them as arrays:

```Javascript
var config = {
_indices : ['pet', 'family'],
_types : ['kitteh', 'canine']
};
```

*Note:* When index, indices, type or types are supplied via operation options, those settings will take precedent over the base configuration for the library:
*Note:* When index or indices are supplied via operation options, those settings will take precedent over the base configuration for the library:

```Javascript

Expand Down Expand Up @@ -193,7 +194,6 @@ Additionally, if there are extra option keys supplied beyond what is required fo
```
var options = {
_index : 'bawss',
_type : 'man',
refresh : true
};
Expand All @@ -214,24 +214,24 @@ For more specifics and details regarding the core API for ElasticSearch, please

*Please Note:* The default timeout is set at 30 seconds... if you are performing a large bulk insert you may need to increase this limit by specifying a higher value for `timeout` in the options parameter.

This method doesn't take into account the underlying config that was used when instantiating the client. It requires index and type to be specified via the commands array or via the options parameter. Conflict will occur if one specifies a different index and type in the options than what is specified via the commands parameter.
This method doesn't take into account the underlying config that was used when instantiating the client. It requires index to be specified via the commands array or via the options parameter. Conflict will occur if one specifies a different index in the options than what is specified via the commands parameter.

At a high level, when performing a bulk update, you must supply an array with an action object followed by the object that the action will use during execution. In the following example, the first item in the array specifies the action is `index` and the second item represents the data to index:

```Javascript
[
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'hamish', breed : 'manx', color : 'tortoise' }
]
```

In this example, two `index` actions will be performed on the 'dieties' index and 'kitteh' type in ElasticSearch:
In this example, two `index` actions will be performed on the 'dieties' index in ElasticSearch:

```Javascript
[
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'dugald', breed : 'siamese', color : 'white' },
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'keelin', breed : 'domestic long-hair', color : 'russian blue' }
]
```
Expand All @@ -246,11 +246,11 @@ var
es = elasticsearch();

var commands = [
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'hamish', breed : 'manx', color : 'tortoise' },
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'dugald', breed : 'siamese', color : 'white' },
{ index : { _index : 'dieties', _type : 'kitteh' } },
{ index : { _index : 'dieties' } },
{ name : 'keelin', breed : 'domestic long-hair', color : 'russian blue' }
];

Expand All @@ -277,8 +277,7 @@ var documents = [
];

var options = {
_index : 'dieties',
_type : 'kitteh'
_index : 'dieties'
}

es.bulkIndex(options, documents, function (err, data) {
Expand All @@ -299,10 +298,9 @@ es.count(function (err, data) {
// teh datas
});

// count docs in a specific index/type
// count docs in a specific index
var options = {
_index : 'bawss',
_type : 'kitteh'
_index : 'bawss'
}

es.count(options, function (err, data) {
Expand Down Expand Up @@ -379,34 +377,34 @@ es.exists({ _index : 'kitteh' }, function (err, data) {

##### Explain

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.
Also requires `_id`, but this must be specified via options.

`es.explain(options, query, callback)`

##### Get

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.
Also requires `_id`, but this must be specified via options.

`es.get(options, callback)`

##### Index

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.

`es.index(options, doc, callback)`

##### More Like This

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.
Also requires `_id`, but this must be specified via options.

`es.moreLikeThis(options, callback)`

##### Multi Get

If `_index` and/or `_type` are supplied via options (or lib config), the will applied to the doc that is transmitted for the operation.
If `_index` is supplied via options (or lib config), the will applied to the doc that is transmitted for the operation.

`es.multiGet(options, docs, callback)`

Expand Down Expand Up @@ -451,7 +449,7 @@ es.search({

##### Update

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.
Also requires `_id`, but this must be specified via options.

`es.update(options, doc, callback)`
Expand Down Expand Up @@ -516,7 +514,7 @@ Requires `_index` be specified either via lib config or via options when calling

##### Delete Mapping

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.

`es.indices.deleteMapping(options, callback)`

Expand Down Expand Up @@ -548,7 +546,7 @@ Requires `_index` be specified either via lib config or via options when calling

##### Put Mapping

Requires `_index` and `_type` be specified either via lib config or via options when calling the operation.
Requires `_index` be specified either via lib config or via options when calling the operation.

`es.indices.putMapping(options, mapping, callback)`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "es",
"description": "API around the ElasticSearch RESTful API -- mostly convenience.",
"main": "dist",
"version": "0.7.4",
"version": "0.8.0",
"author": "Nick Campbell (http://github.com/ncb000gt)",
"contributors": [
"Nick Campbell (http://github.com/ncb000gt)",
Expand Down

0 comments on commit 5e7ea5a

Please sign in to comment.