From 0d7adcea2f2d04a5a8dd830a070bb69dd513fac0 Mon Sep 17 00:00:00 2001 From: Sebastian Guesdon Date: Thu, 14 Nov 2019 12:01:24 +0100 Subject: [PATCH 1/2] Indexing _id field of nested objects (close #57) --- lib/mapping.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mapping.js b/lib/mapping.js index bcf5a5f..3df0aba 100644 --- a/lib/mapping.js +++ b/lib/mapping.js @@ -12,7 +12,7 @@ module.exports.generate = generate; * @param {integer} [version] * @returns {Object} */ -function generate(schema, version) { +function generate(schema, version, isRoot = true) { const mapping = {}; const typeKey = getTypeKey(schema); const explicit = hasExplicit(schema, typeKey); @@ -20,7 +20,7 @@ function generate(schema, version) { Object.keys(schema.paths).forEach(name => { // ignore _id because is used as index - if (name === '_id') { + if (name === '_id' && isRoot) { return; } @@ -67,7 +67,7 @@ function generate(schema, version) { if (!{}.hasOwnProperty.call(options, 'es_value') || !options.es_type) { if (isEmbedded(type)) { current.type = 'object'; - current.properties = generate(path.schema, version); + current.properties = generate(path.schema, version, false); } if (defaultTypes[type]) { current.type = defaultTypes[type]; From 18a993eaa61bc820294d00d0370741229d819031 Mon Sep 17 00:00:00 2001 From: Sebastian Guesdon Date: Fri, 24 Apr 2020 15:00:33 +0200 Subject: [PATCH 2/2] =?UTF-8?q?fix=20cr=C3=A9ation=20des=20analysers=20sur?= =?UTF-8?q?=20la=20version=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 070440e..298f401 100644 --- a/lib/index.js +++ b/lib/index.js @@ -157,7 +157,7 @@ function createMapping(settings, callback, version) { if (version === 7) { // Keep shards settings like the previous versions if (!createIndexOpts.body.settings) { - createIndexOpts.body = { settings: {} }; + createIndexOpts.body = { settings }; } createIndexOpts.body.settings.number_of_shards = settings.number_of_shards || 5;