enrise-estools
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -0,4 +1,6 @@ | ||
'use strict'; | ||
module.exports = { | ||
upgrade: require('./src/upgrade'), | ||
helpers: require('./src/helpers') | ||
}; | ||
}; |
{ | ||
"name": "enrise-estools", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Elasticsearch tooling functions for managing indices and aliases.", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://gitlab.enrise.com/Enrise/estooling" | ||
"url": "https://gitlab.enrise.com/Enrise/estools" | ||
}, | ||
@@ -11,0 +11,0 @@ "scripts": { |
@@ -53,2 +53,3 @@ # Enrise estools | ||
Ensure your working directory is clean. The following commands create a new version number by updating the package.json file and adding a git tag. Then push the new version with the tag to git, where GitLab CI will publish a new version. | ||
Version should only be updated by npm version, do not manually update the version in package.json. | ||
``` | ||
@@ -63,2 +64,2 @@ npm version <newversion> | ||
- [ ] CLI tooling. When installing, this should be placed inside `./node_modules/.bin`. | ||
- [ ] Improve description | ||
- [ ] Improve description |
@@ -86,5 +86,14 @@ 'use strict'; | ||
prepareSynonymFilter(filters, 'synonyms', synonyms.synonyms); | ||
prepareSynonymFilter(filters, 'pre_synonyms', synonyms.preSynonyms); | ||
preparePreSynonymsFilters(filters, synonyms.preSynonyms); | ||
} | ||
function preparePreSynonymsFilters(filters, preSynonyms) { | ||
const preSynonymsTargets = _.filter(['pre_synonyms', 'pre_synonyms_search', 'pre_synonyms_index'], | ||
property => _.has(filters, property)); | ||
if (_.isEmpty(preSynonymsTargets)) { | ||
throw new Error('No pre_synonyms, pre_synonyms_search or pre_synonyms_index filter found'); | ||
} | ||
_.each(preSynonymsTargets, target => prepareSynonymFilter(filters, target, preSynonyms)); | ||
} | ||
function prepareSynonymFilter(filters, name, synonyms) { | ||
@@ -91,0 +100,0 @@ const filter = filters[name]; |
@@ -363,3 +363,44 @@ 'use strict'; | ||
}); | ||
it('will use pre_synonyms_search when it is the only available target', () => { | ||
delete mapping1.settings.analysis.filter.pre_synonyms; | ||
mapping1.settings.analysis.filter.pre_synonyms_search = {synonyms: []}; | ||
helpers.prepareSynonymsMapping(mapping1, synonyms); | ||
chai.expect(mapping1.settings.analysis.filter).to.deep.equal({ | ||
synonyms: {synonyms: ['some,synonyms']}, | ||
pre_synonyms_search: {synonyms: ['pre_some,pre_synonyms']}, | ||
other_filter: {} | ||
}); | ||
}); | ||
it('will use pre_synonyms_index when it is the only available target', () => { | ||
delete mapping1.settings.analysis.filter.pre_synonyms; | ||
mapping1.settings.analysis.filter.pre_synonyms_index = {synonyms: []}; | ||
helpers.prepareSynonymsMapping(mapping1, synonyms); | ||
chai.expect(mapping1.settings.analysis.filter).to.deep.equal({ | ||
synonyms: {synonyms: ['some,synonyms']}, | ||
pre_synonyms_index: {synonyms: ['pre_some,pre_synonyms']}, | ||
other_filter: {} | ||
}); | ||
}); | ||
it('will use all pre_synonyms* properties when they are available', () => { | ||
mapping1.settings.analysis.filter.pre_synonyms_index = {synonyms: []}; | ||
mapping1.settings.analysis.filter.pre_synonyms_search = {synonyms: []}; | ||
helpers.prepareSynonymsMapping(mapping1, synonyms); | ||
chai.expect(mapping1.settings.analysis.filter).to.deep.equal({ | ||
synonyms: {synonyms: ['some,synonyms']}, | ||
pre_synonyms: {synonyms: ['pre_some,pre_synonyms']}, | ||
pre_synonyms_index: {synonyms: ['pre_some,pre_synonyms']}, | ||
pre_synonyms_search: {synonyms: ['pre_some,pre_synonyms']}, | ||
other_filter: {} | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37758
14
783
64