0

Suppose I created an index using:

db.collections.createIndex({'key': 1})

then will all new documents added to the collection with field 'key' automatically added in the index? Or do I need to run reIndex() after certain number of new documents?

conquester
  • 1,082
  • 2
  • 21
  • 44
  • 1
    Of course it updates every time something is written. This is how indexes work. Also answered in the documentation: ["How to Write Operations Affect Indexes"](https://docs.mongodb.org/manual/faq/indexes/#how-do-write-operations-affect-indexes) – Blakes Seven Apr 10 '16 at 05:37
  • See also [Why and when is necessary to rebuild indexes in MongoDB?](http://stackoverflow.com/a/30366749/2313887) – Neil Lunn Apr 10 '16 at 05:45

0 Answers0