From f231d7bb49439716e20b054120ad43182b3d8ca6 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Wed, 24 Mar 2021 16:59:54 -0400 Subject: [PATCH] should work and is designed to handle multiple text fields --- lib/model.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/model.js b/lib/model.js index 5ff590a4e15..26dd0ea674e 100644 --- a/lib/model.js +++ b/lib/model.js @@ -1633,9 +1633,15 @@ function _ensureIndexes(model, options, callback) { const indexFields = utils.clone(index[0]); const indexOptions = utils.clone(index[1]); - const textBlock = Object.keys(indexFields).map(function(key) { - return indexFields[key]; - }); + const textBlock = () => { + const results = Object.keys(indexFields).map(function(key) { + return indexFields[key]; + }); + if (!results.includes('text')) { + return true; + } + return false; + }; delete indexOptions._autoIndex; _decorateDiscriminatorIndexOptions(model, indexOptions); if ('safe' in options) { @@ -1655,7 +1661,7 @@ function _ensureIndexes(model, options, callback) { indexOptions.background = options.background; } if (model.schema.options.hasOwnProperty('collation') && - !indexOptions.hasOwnProperty('collation') && textBlock != 'text') { + !indexOptions.hasOwnProperty('collation') && textBlock()) { indexOptions.collation = model.schema.options.collation; }