I've read the docs of mongodb and get to know that if I want to do text search I should use create index
. But can I create index for each data during insert process? If I can, how should I do?
The index is created once for a collection, i.e. for text index do this
db.yourCollection.createIndex({yourText:"text"})
The index is updated automatically on every insert operation. You don't have to do this manually but have it in mind. This is what makes insert operations expensive. The more indexes you have the longer it takes to insert a document and update all of them.
If you want a link to the documentation, this topic is faced here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With