【MongoDB】The Regex Expression query of MongoDB,mongodbregex

來源:互聯網
上載者:User

【MongoDB】The Regex Expression query of MongoDB,mongodbregex

In the past two blogs, the topic mainly focus on the high query operation of mongodb.In this blog, we simply study the regex expression in the mongdb.  MongoDB also support the regex query. For example


The expression is also able to combination with other expression.



Notes: /^a/; /^a.*/; /^a.*$/ have the same result, however the later two have less efficiency than the first one. Because the later will scan all the things, but the first only scan the first character. 

The item:

-i : ignore the upper or low case 

-m: the begin '^' and end'$' do work on every new line;

-x: ignore the blank character

-s:  since 1.9 version, adding it could make '.' reprent all the character. 

for example:

/a.*b/ does not matches "apple\nbanana" but /a.*b/s does. 





the expressions of 還是the expression of

根據它後邊跟的中心詞來確定。expression是可數名詞。
 
【MongoDB】怎停止MongoDB伺服器

如果伺服器是作為前台進程運行在終端的,就直接按Ctrl-C。否則,就用kill這種命令發出訊號。如果mongod的PID是10014,就可以用kill -2 10014(SIGINT)或者kill 10014(SIGTERM)。
當mongod收到SIGINT或者SIGTERM時,會穩妥退出。也就是說會等到當前啟動並執行操作或檔案預分配完成(需要一些時間),關閉所有開啟的串連,將緩衝的資料重新整理到磁碟,最後停止。 千萬不要向運行中的MongoDB發送SIGKILL(kill -9)。這樣會導致資料庫直接關閉,上面降到的步驟都將被忽略,這會使資料檔案損毀。
 

相關文章

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.