mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Setting autoSearchIndex to true dont create search index

Open creativearmenia opened this issue 1 year ago • 0 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.17.0

Node.js version

24.3.0

MongoDB server version

6.x

Typescript version (if applicable)

5.9.2

Description

Setting autoSearchIndex to true do not create search index

calling init() on model throws error that this.ensureSearchIndexes is not a function

the only way to create search index now is to await on createSearchIndexes() on model

Steps to Reproduce

 1097 |     );
 1098 |     if (!autoSearchIndex) {
 1099 |       return;
 1100 |     }
 1101 | 
 1102 |     return await this.ensureSearchIndexes();
                              ^
 TypeError: this.ensureSearchIndexes is not a function. (In 'this.ensureSearchIndexes()', 'this.ensureSearchIndexes' is undefined)
      at <anonymous> (/usr/src/app/node_modules/mongoose/lib/model.js:1102:23)
      at _createSearchIndexes (/usr/src/app/node_modules/mongoose/lib/model.js:1091:32)

Expected Behavior

No response

creativearmenia avatar Aug 04 '25 14:08 creativearmenia