We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do you want to request a feature or report a bug? bug
What is the current behavior? I'm running .syncIndexes() and the mongoose is recreating text index every time.
If the current behavior is a bug, please provide the steps to reproduce.
const mongoose = require('mongoose'); (async function () { const collation = { collation: { locale: 'simple' } }; const connection = await mongoose.createConnection('mongodb://localhost:27017/test-db').asPromise(); const someSchema = new mongoose.Schema({ title: String, author: String, }); someSchema.index({ title: 1, author: 'text' }, collation); const model = connection.model('Some', someSchema); mongoose.set('debug', true); await model.syncIndexes({ background: false }); process.exit(0); })();
What is the expected behavior? If the text index is the same, .syncIndexes() shouldn't recreate it every time.
In isIndexEqual we should check db index weights + key (with omiting 2 properties: _fts + _ftsx) Something like this one:
isIndexEqual
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version. node: 14.16.1 mongoose: 6.0.9 MongoDB: 4.4
The text was updated successfully, but these errors were encountered:
const mongoose = require('mongoose'); (async function () { const collation = { collation: { locale: 'simple' } }; const connection = await mongoose.createConnection('mongodb://localhost:27017/test-db').asPromise(); const someSchema = new mongoose.Schema({ title: String, author: String, }); someSchema.index({ title: 1, author: 'text' }, collation); const model = connection.model('Some', someSchema); mongoose.set('debug', true); await model.syncIndexes({ background: false }); // await model.syncIndexes({ background: true}); await model.collection.dropIndexes(); await mongoose.connection.dropDatabase(); })();
Sorry, something went wrong.
dbIndex.key
const weight
dbIndex.weights
Your solution was correct
Merge pull request #10851 from Automattic/gh-10850
725cad9
fix 10850 by removing two properties from the `dbIndex.key` and assigning whats left to `const weight` with `dbIndex.weights`
Successfully merging a pull request may close this issue.
Do you want to request a feature or report a bug?
bug
What is the current behavior?
I'm running .syncIndexes() and the mongoose is recreating text index every time.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
If the text index is the same, .syncIndexes() shouldn't recreate it every time.
In
isIndexEqual
we should check db index weights + key (with omiting 2 properties: _fts + _ftsx)Something like this one:
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
node: 14.16.1
mongoose: 6.0.9
MongoDB: 4.4
The text was updated successfully, but these errors were encountered: