Skip to content

Setting autoSearchIndex to true dont create search index #15565

Closed

Description

@creativearmenia

Prerequisites

  • I have written a descriptive issue title
  • 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

Activity

  1. added a commit that references this issue on Aug 4, 2025
    636aa1c
  2. added a commit that references this issue on Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions