Example usage for org.springframework.data.mongodb.core.query BasicQuery limit

List of usage examples for org.springframework.data.mongodb.core.query BasicQuery limit

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query BasicQuery limit.

Prototype

public Query limit(int limit) 

Source Link

Document

Limit the number of returned documents to limit .

Usage

From source file:com.card.loop.xyz.dao.LearningElementDAO.java

public List<LearningElement> searchLE(String keyword) {
    //return mongoOps.findAll(LearningElement.class);
    //Query query = new Query();
    BasicQuery query = new BasicQuery("{\"title\": {$regex : '/" + keyword + "/'} }");
    //       System.out.println(query+"HAHA");
    query.limit(10);
    //query.addCriteria(where("title").is(keyword).orOperator(where("subject").is(keyword)).orOperator(where("description").is(keyword)));
    //query.addCriteria(Criteria.where("title").regex(keyword));
    System.out.println(query);/*from w  w  w.j  a  v a  2  s .c o  m*/
    //return mongoOps.find(query(where("title").regex(keyword)), LearningElement.class);
    return mongoOps.find(query(where("status").is(1)), LearningElement.class);
}