TTL index of MongoDB Learning notes, partial index and text index

Source: Internet
Author: User

TTL index:

The TTL collection enables MongoDB to set the expiration time for stored data, after a specified period of time, or at a specified point in time, the collection is automatically cleared by Mongod. This feature facilitates the storage of some data that only needs to be kept for a certain amount of time, such as event data generated by the machine, logs, session information, and so on.

First create a collection ttlcol:

The TTL index is created and expires in 60 seconds.

After 60 seconds, the query found that the data was deleted.

Partial index:

The MongoDB partial index creates an index only for those documents that meet the specified filter criteria in a collection. Because part of the index is a subset of a collection document, some indexes have lower storage requirements and reduce the performance cost of index creation and maintenance. Partial indexes are created by specifying filter conditions and can use partial indexes for all index types supported by MongoDB.

After you force a partial index, you can only query the records of the rating>12.

Text index:

You can search for some of the words in the article:

TTL index of MongoDB Learning notes, partial index and text index

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.