{"action":"opened","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/4127","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/4127/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/4127/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/4127/events","html_url":"https://github.com/Automattic/mongoose/issues/4127","id":153285909,"number":4127,"title":"mongoose silently ignores a problem if it cannot create the text index","user":{"login":"dportabella","id":976546,"avatar_url":"https://avatars.githubusercontent.com/u/976546?v=3","gravatar_id":"","url":"https://api.github.com/users/dportabella","html_url":"https://github.com/dportabella","followers_url":"https://api.github.com/users/dportabella/followers","following_url":"https://api.github.com/users/dportabella/following{/other_user}","gists_url":"https://api.github.com/users/dportabella/gists{/gist_id}","starred_url":"https://api.github.com/users/dportabella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dportabella/subscriptions","organizations_url":"https://api.github.com/users/dportabella/orgs","repos_url":"https://api.github.com/users/dportabella/repos","events_url":"https://api.github.com/users/dportabella/events{/privacy}","received_events_url":"https://api.github.com/users/dportabella/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-05T17:52:07Z","updated_at":"2016-05-05T17:52:07Z","closed_at":null,"body":"let's say I create a database as follows:\r\n\r\n```\r\nvar ProductSchema = new mongoose.Schema({title: String, price: Number}).index({title: \"text\"});\r\nvar Product = mongoose.model('Product', ProductSchema);\r\nProduct.create({title: 'book1', price: 100});\r\n```\r\nand populate it with data.\r\nlater, I realize that I want to add a description, and text index it also, so I change my program and run on the already populated database:\r\n\r\n```\r\nvar ProductSchema = new mongoose.Schema({title: String, price: Number, description: String}).index({title: \"text\", description: \"text\"});\r\nvar Product = mongoose.model('Product', ProductSchema);\r\nProduct.create({title: 'book2', price: 200, description: 'better'});\r\n```\r\n\r\nso, I have book1 and book2, and I would expect that I have the new text index set-up.\r\nBut that's not the case; Mongoose didn't create the text index (with title and description) because it already existed a text index (with only title). (mongodb only allows one text index shared across the requested fields).\r\n\r\n`mongoose.model` silently ignored the problem, and this is not an acceptable behavior. Instead, it should either:\r\n- delete the previous text index and create the new one.\r\n- or throw an error\r\n\r\nThe developer can detect this problem by calling `Product.ensureIndexes`. But i still think that `mongoose.model` should either execute what is asked or fail, instead of silently ignoring the problem.\r\n\r\n"}}