Mongodb failed to insert document due to too much data? !

  node.js, question

Enter a large section of content in the text field and find that it cannot be inserted into the collection. It seems that the maximum limit for insertion has been exceeded. How can we resolve this situation? !

图片描述

This error should refer to this of the indexlimit

The total size of an index entry, which can include structural overhead depending on the BSON type, must be less than 1024 bytes.

The content of the indexed field should be less than 1024 bytes. Please look at the rest of the document for related questions.
Usually we use indexed fields for comparison such as eq/lt(e)/gt(e). The purpose of indexing is to speed up retrieval. However, too long fields will significantly reduce the retrieval speed and make the insertion/update efficiency very poor. This is why the index of The length of the field should be restricted. Therefore, your request is actually contradictory. On the one hand, you want to speed up the retrieval through the index; on the other hand, such a long content will hinder this purpose. If you look at relational databases, such as MySQL, there are similar restrictions. Therefore, what you need to solve is not how to insert such a long field, but why to search for a document by comparing such a long field?