MongoDB Fuzzy Query command

Source: Internet
Author: User
Tags mongodb mongodb query

Command-line query:

1, you can use. * To fuzzy query, the following is the query surname Chen user.

Db.customers.find ({name:/Chen */i});

2, also can not carry * number

Db.fs.files.find ({filename:/install_mongo.sh/i})

PHP Query:

$query =array ("Name" =>newmongoregex ("/.*". $name. "). */i "));
$db->find ($query);

Simple tens of thousands of data does not matter, but more than 2 million data, the text field for fuzzy query, basic find out, how to improve query efficiency

Solutions

English is built full text index, Chinese well, hehe, want to find another Full-text indexing scheme to help, such as Elasticsearch

Can use Lucence/sphinx combine MongoDB to do search query, MongoDB query efficiency is indeed relatively low

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.