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

Disable creation of certain Mongo indexes? #393

Open
clarkritchie opened this issue Dec 11, 2015 · 6 comments
Open

Disable creation of certain Mongo indexes? #393

clarkritchie opened this issue Dec 11, 2015 · 6 comments

Comments

@clarkritchie
Copy link

Hi and thanks for this package!

It looks like this package automatically creates a bunch of Mongo indexes when the app starts up.

Is there any way to tell it to not create a specific index? I'm occasionally getting a MongoError: E11000 duplicate key error on a field that I don't ever need to search on.

I noticed I can:

  • db.users.getIndexes() -- see the problem index
  • db.users.dropIndex('services.phone.verify.code_1'); -- index is gone
  • restart app, index comes back
  • meteor remove easy:search -- for testing
  • restart app, no indexes
  • meteor add easy:search
  • restart app -- see the problem index
@matteodem
Copy link
Owner

Yes that might be the case, are you using the MongoTextIndex package? It creates a text index for the fields that you want to search on. You don't need to specify those fields as you could add a custom selector method to add other functionality in there.

Please show me an example of your configuration.

@clarkritchie
Copy link
Author

No, I'm not using MongoTextIndex. As above, when I add this package, I see the index in the db. When I remove this package, the index goes away.

@matteodem
Copy link
Owner

You don't have any configuration at all? Simply adding the package creates indexes? Please show me the EasySearch related code from your app.

@clarkritchie
Copy link
Author

Pretty much this:

// setup specific server-side EasySearch search indexes
if (Meteor.isServer) {
    // good configuration examples:  https://github.com/matteodem/easy-search-leaderboard/blob/master/leaderboard.js
    VouchersIndex = new EasySearch.Index({
        collection: Vouchers,
        defaultSearchOptions: {
            limit: 10000 // total WAG
        },
        fields: ['code', 'identifier'],
        engine: new EasySearch.MongoDB()
    });

    OrdersIndex = new EasySearch.Index({
        collection: Orders,
        defaultSearchOptions: {
            limit: 10000 // total WAG
        },
        fields: ['userId'],
        engine: new EasySearch.MongoDB()
    });

    PaymentsIndex = new EasySearch.Index({
        collection: Payments,
        defaultSearchOptions: {
            limit: 10000 // total WAG
        },
        fields: ['senderPhone', 'transactionReference', 'firstName', 'lastName'],
        engine: new EasySearch.MongoDB()
    });

    UsersIndex = new EasySearch.Index({
        collection: Meteor.users,
        defaultSearchOptions: {
            limit: 10000 // total WAG
        },
        fields: ['profile.name', 'phone.number'],
        engine: new EasySearch.MongoDB()
    });
}

@matteodem
Copy link
Owner

I'll lower the priority of this as the only place in the core code that touches / creates an index is when the MongoTextIndex engine is used. See here

@matteodem matteodem added bug and removed enhancement labels Sep 19, 2021
@matteodem
Copy link
Owner

This seems to have created problems with other users too so I'l prioritize this 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