Skip to content
New issue

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

Changing Mongo text index doesn't check for an existing text index. #486

Closed
tcastelli opened this issue Apr 13, 2016 · 1 comment
Closed

Comments

@tcastelli
Copy link

I have run into this problem when trying to change the mongotext index fields. Would it be possible to automatically drop the previous text index before creating the new one(or disabling it's creation?) #393
(Since we don't know the previous index name I guess we need to loop through indexes with collection._getIndexes() and check which one has the text type)

W20160413-16:12:07.853(2)? (STDERR) C:\Users\xxx\AppData\Local\.meteor\packages\meteor-tool\1.3.1\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:278
W20160413-16:12:07.854(2)? (STDERR)                         throw(ex);
W20160413-16:12:07.854(2)? (STDERR)                               ^
W20160413-16:12:07.854(2)? (STDERR) MongoError: Index with pattern: { _fts: "text", _ftsx: 1 } already exists with different options
W20160413-16:12:07.855(2)? (STDERR)     at Object.Future.wait (C:\Users\xxx\AppData\Local\.meteor\packages\meteor-tool\1.3.1\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:398:15)
W20160413-16:12:07.855(2)? (STDERR)     at MongoConnection.meteorInstall.node_modules.meteor.mongo.mongo_driver.js.MongoConnection._ensureIndex (packages/mongo/mongo_driver.js:790:10)
W20160413-16:12:07.855(2)? (STDERR)     at OptimizedApply (packages\meteorhacks_kadira.js:291:17)
W20160413-16:12:07.855(2)? (STDERR)     at Object.MongoInternals.RemoteCollectionDriver.open._.each.ret.(anonymous function) [as _ensureIndex] (packages\meteorhacks_kadira.js:3241:16)
W20160413-16:12:07.856(2)? (STDERR)     at [object Object].meteorInstall.node_modules.meteor.mongo.collection.js.Mongo.Collection._ensureIndex (packages/mongo/collection.js:664:20)
W20160413-16:12:07.856(2)? (STDERR)     at meteorInstall.node_modules.meteor.easysearch:core.lib.engines.mongo-text-index.js.MongoTextIndexEngine.getSearchCursor (packages/easysearch:core/lib/engines/mongo-text-index.js:45:30)
W20160413-16:12:07.856(2)? (STDERR)     at MongoTextIndexEngine.onIndexCreate (packages/easysearch:core/lib/engines/mongo-text-index.js:45:7)
W20160413-16:12:07.857(2)? (STDERR)     at new Index (packages/easysearch:core/lib/core/index.js:31:19)
W20160413-16:12:07.857(2)? (STDERR)     at meteorInstall.lib.collections_schemas_both._collections.js (lib/collections_schemas_both/_collections.js:25:18)
=> Exited with code: 8
W20160413-16:12:07.857(2)? (STDERR)     at fileEvaluate (packages\modules-runtime.js:158:9)
W20160413-16:12:07.858(2)? (STDERR)     at Object.toError (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\utils.js:114:11)
W20160413-16:12:07.858(2)? (STDERR)     - - - - -
W20160413-16:12:07.859(2)? (STDERR)     at Server.Base._callHandler (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\connection\base.js:453:41)
W20160413-16:12:07.859(2)? (STDERR)     at Server.connect.connectionPool.on.server._serverState (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\connection\server.js:488:18)
W20160413-16:12:07.860(2)? (STDERR)     at [object Object].Server.connect.connectionPool.on.server._serverState (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\connection\server.js:446:20)
W20160413-16:12:07.859(2)? (STDERR)     at Db.createIndex (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\db.js:1354:26)
W20160413-16:12:07.860(2)? (STDERR)     at [object Object].MongoReply.parseBody (C:\Usersxxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:68:5)
W20160413-16:12:07.861(2)? (STDERR)     at [object Object]._connect (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:207:13)
W20160413-16:12:07.860(2)? (STDERR)     at [object Object].emit (events.js:95:17)
W20160413-16:12:07.861(2)? (STDERR)     at [object Object].emit (events.js:98:17)
W20160413-16:12:07.861(2)? (STDERR)     at Socket.exports.Connection.createDataHandler (C:\Users\xxx\AppData\Local\.meteor\packages\npm-mongo\1.4.42\npm\node_modules\mongodb\lib\mongodb\connection\connection.js:440:22)
@matteodem
Copy link
Owner

I'm not sure if that's the preferred way of handling things. I think people should explicitely configure their collections to have no index, so that easy-search then can create those. Otherwise this library might delete indexes that are needed as they are right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants