Skip to content

Commit

Permalink
remove _type (#157)
Browse files Browse the repository at this point in the history
Remove references to `_type` from this repo in order to support elasticsearch v8.

Prior to version 6 `_type` was recommended to be "_doc", in es7 it was optional (but if specified it was required to be "_doc"), in es8 it's not allowed at all.

See: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html

BREAKING CHANGE: Pelias no longer supports elasticsearch v6

This change drops support for elasticsearch v6 in order to support v8.
The current recommended version remains v7.
  • Loading branch information
missinglink authored Mar 13, 2024
1 parent 83b64de commit 6cfffc0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
4 changes: 0 additions & 4 deletions Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ Document.prototype.toESDocument = function() {
return {
_index: _.get(config, 'schema.indexName', 'pelias'),
_id: this.getGid(),
// In ES7, the only allowed document type will be `_doc`.
// However underscores are not allowed until ES6, so use `doc` for now
// see https://github.com/elastic/elasticsearch/pull/27816
_type: _.get(config, 'schema.typeName', 'doc'),
data: doc
};
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"lodash": "^4.6.1",
"pelias-config": "^4.5.0",
"pelias-config": "^6.0.0",
"through2": "^3.0.0"
},
"devDependencies": {
Expand Down
6 changes: 1 addition & 5 deletions test/document/toESDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const codec = require('../../codec');

var fakeGeneratedConfig = {
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand Down Expand Up @@ -50,7 +49,6 @@ module.exports.tests.toESDocument = function(test) {

var expected = {
_index: 'example_index',
_type: 'example_type',
_id: 'mysource:mylayer:myid',
data: {
layer: 'mylayer',
Expand Down Expand Up @@ -102,7 +100,6 @@ module.exports.tests.toESDocument = function(test) {

var expected = {
_index: 'example_index',
_type: 'example_type',
_id: 'mysource:mylayer:myid',
data: {
source: 'mysource',
Expand Down Expand Up @@ -156,7 +153,6 @@ module.exports.tests.toESDocument = function(test) {

var expected = {
_index: 'example_index',
_type: 'example_type',
_id: 'mysource:mylayer:myid',
data: {
source: 'mysource',
Expand Down

0 comments on commit 6cfffc0

Please sign in to comment.