Mongodb fuzzy query tutorial, mongodb fuzzy query
Use the RockMongo client tool for fuzzy search
{"Content": "$ regex": "123456 "}
Fuzzy search in other cases
Query contains XXX
{Name:/xxx /}
Query starts with XXX
{Name:/^ xxx /}
Query ends with XXX
{Name:/xxx ^ /}
Case Insensitive Query
{Name:/xxx/I}
Case-insensitive fuzzy search in Spring
// Completely match Pattern pattern = Pattern. compile ("^ Wang $", Pattern. CASE_INSENSITIVE); // The right matches Pattern pattern = Pattern. compile ("^. * Wang $ ", Pattern. CASE_INSENSITIVE); // The left matches Pattern pattern = Pattern. compile ("^ Wang. * $ ", Pattern. CASE_INSENSITIVE); // fuzzy match Pattern pattern = Pattern. compile ("^. * Wang. * $ ", Pattern. CASE_INSENSITIVE); Query query = Query. query (Criteria. where (fieldName ). regex (pattern); List
Users = jsontemplate. find (query, SimpleUserInfo. class, classname); return users;