This example for you to share the Java Operation MongoDB Fuzzy query and paging query for your reference, the specific contents are as follows
Fuzzy query conditions:1. Perfect MatchPattern pattern = pattern.compile ("^name$", pattern.case_insensitive);2, right matchingPattern pattern = pattern.compile ("^.*name$", pattern.case_insensitive);3, left matchPattern pattern = pattern.compile ("^name.*$", patter
returns the span of the specified data2.1 Querying the data from the 5~10 bar in the persons documentDb.persons.find ({},{_id:0,name:1}). Limit (5). Skip (5)3.Sort returns data sorted by age [1,-1]Db.persons.find ({},{_id:0,name:1,age:1}). Sort ({age:1})Note: MongoDB keys can be sorted with different types of data and also have priorityMinimum valueNullDigitalStringObjects/DocumentsArrayBinaryObject IDBooleanDateTime stamp à regular à maximum value4.
Sort with sort, equal to order by, ascending in 1, descending with-1For example, by age word Che order:
The code is as follows
Copy Code
Db.user.find (). Sort ({"Age": 1})
If you have more than one field, descending by name, age ascending
The code is as follows
Copy Code
Db.user.find (). Sort ({"Name":-1, "Age": 1})
Limit with skip, equivalent to the limit in MySQL:
The code is as follows
Copy Code
Http://www.cnblogs.com/xiaolai/p/3401289.html
MongoDB paging query is done by limit (), skip (), sort (), which is a combination of three functions for paging queries.
Here's my test data.
Db.test.find (). Sort ({"Age": 1});
The first of these methods
Query the first page of data: Db.test.find (). Sort ({"Age": 1}). Limit (2);
Query the data for the second pag
) Update.set () with filter modification (recommended)
Vi. Inline Array Lookup element operations (LINQ)
(i) LINQ query a record (recommended)
(ii) LINQ query paging (recommended)
Vii. Summary
First, preface本教程是入门基础教程,主要是笔者在项目中使用MongoDB .Net官方驱动对MongoDB内嵌文档的操作时遇到了很多不方便的情况,踩了很多的坑,所以单独整理出来一篇文章,来讲一讲笔者踩坑的过程。The author's level
Tags: status pos count tar stat list operator Opera createPublic page if (page page=1; } Sort sort = new sort (Sort.Direction.DESC, "createtime"); pageable pageable = new Pagerequest (page-1,size,sort); Query query = new query (); condition ID =xx Criteria = Criteria.where ("CallerID"). Is (Recorded.getcallerid ()); Criteria.and ("status"). is (recorded.success); if (starttime!=nullendtime!=null) { Criteria.andoperator ( Criteria.where ("Createtime"). GTE (StartTime), Criteria.where ("Createtime
1. Inserting experimental dataLazy to use the samus,100 bar.1 for(inti =0; I -; i++)2 {3Document doc =NewDocument ();4doc["ID"] =i;5doc["MSG"] ="value is"+i;6 Mongocollection.insert (DOC);7}Insert Successful2. PagingMethod One: Through the Sike () and the Limit () method, for example,by Db.myCollection.find (). Sort ({"ID": 1}). Skip (10) command, after sorting it by ID, skip 10, Query 10, and the result is 10-19 data.This is similar to the operation of the Skip
Label:Some basic statements about MongoDB data paging and sorting Limit,skip users, introducing MongoDB data paging and sorting instance methods. Use skip and limit to do data paging as follows: Code: Page1 = Db.things.find (). Limit (20) Page2 = Db.things.find (). Skip (+).
Recent projects in the site user data to do new visitors statistics, data stored in MongoDB, the statistics are not really big, 1000W up and down, but the company only allocated to my 4G memory computer, let me program run up breathless ... It's exhausting.The most common problem is querying MongoDB memory Overflow , there is no way to only paged query. This kind of thought everyone may think, but how to pa
To get data in groups:
Db.express_info.group ({"key": {"Express_code": true}, "initial": {"num": "0", "mobile": "0"}, "reduce": function (Doc, Result) {result.num++, result.mobile=doc.mobile}, ' condition ': {' mobile ': ' 18663930231 '}, ' Finalize ': function (Result ) {result.is_push=result.num+1}})Analysis:
Key: Columns used in groupsInitial: Set initial return elementReduce:doc is the document in the collection, and result is the initial initialCondition: Query CriteriaFinalize: Process a
last time in a two G of Memory Win Server run a program on the computer, after some time Mongod Auto Stop, found that the log file finally has such an error:2014-11-30t00:32:32.914+0800 [conn30751] command taskdb. $cmd Command:count {count: "Result25", Fields:null, query: {MD 5: "C390a22da3d411675883d6f692f266de"}} plansummary:collscan keyupdates:0 numyields:0 locks (micros) r:312476 Reslen : 312ms2014-11-30t00:32:32.921+0800 [conn30751] virtualprotect for d:/data/db/taskdb/taskdb.3 Chunk 4122 f
Paging query on the basis of the previous article Spring Data MongoDB Environment defines a common paging parameter class that implements the Pageable interface
Import java.io.Serializable;
Import org.springframework.data.domain.Pageable;
Import Org.springframework.data.domain.Sort;
public class Springdatapageable implements Serializable, pageable {priva
[Share] mysql-based paging program full solution (including normal paging/segmented paging/original paging/Weibo since_id paging) this blog address: complete solution for mysql-based paging programs (including common
[Share] mysql-based paging program full solution (including normal paging, segmented paging, original paging, and since_id paging) this blog address: blog. csdn. netlgg201articledetails7757494 the source code involved in this article can be downloaded in. csdn. download netu
the powerful query functions of MongoDB, and queries by operators such as $ in, $ or, $ ne, $ lt, and $ gt)Lecture 8: MongoDB query syntax 2 (describes in detail the powerful query functions of MongoDB, such as regular expression query, array query, and embedded document query)Lecture 9: MongoDB query syntax 3 (detail
Physical paging and logical paging, physical paging logical Paging1 Overview 1. Physical Paging
Physical paging depends on a physical entity, which is a database. For example, MySQL database provides the limit keyword. Programmers only need to write SQL statements with the
MongDB basic learning (5) -- projection, paging, sorting, aggregation, and mongdb Paging
MongDB basic learning (5) -- projection, paging, sorting, and aggregation
Basic syntax Learning
The Chinese New Year is coming soon, tomorrow is a lover, and the day after tomorrow is coming soon. I hope I can finish chapter 5 and chapter 6 before the holiday. I am very happy
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.