Package org.springframework.data.mongodb.core.query

Examples of org.springframework.data.mongodb.core.query.Query.limit()


    MongoQueryCreator creator = new MongoQueryCreator(tree, accessor, context, isGeoNearQuery);
    Query query = creator.createQuery();

    if (tree.isLimiting()) {
      query.limit(tree.getMaxResults());
    }

    TextCriteria textCriteria = accessor.getFullText();
    if (textCriteria != null) {
      query.addCriteria(textCriteria);
View Full Code Here


  }

  @Test
  public void testQueryWithLimit() {
    Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22));
    q.limit(50);
    String expected = "{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}";
    Assert.assertEquals(expected, q.getQueryObject().toString());
    Assert.assertEquals(50, q.getLimit());
  }
View Full Code Here

        query.setLevel("ERROR");
        query.setKeyWord("111");
        System.out.println(query.toQuery().toString());

        Query bquery = new BasicQuery(query.toQuery());
        bquery.limit(100);

        bquery.sort().on("$timestamp", Order.DESCENDING);
        System.out.println(bquery.getQueryObject());
        System.out.println(bquery.getFieldsObject());
        System.out.println(bquery.getSortObject());
View Full Code Here

    public DBCursor findLogs(String projectName, LogQuery logQuery, int max) throws ParseException {
        Project project = projectService.findProject(projectName);
        MongoTemplate template = project.fetchMongoTemplate();

        Query query = new BasicQuery(logQuery.toQuery());
        query.limit(max);

        query.sort().on("timestamp", Order.DESCENDING);
        logger.debug("find logs from {}  by query {} by sort {}", new Object[]{project.getLogCollection(), query.getQueryObject(), query.getSortObject()});
        DBCursor cursor = template.getCollection(project.getLogCollection()).find(query.getQueryObject()).sort(query.getSortObject()).limit(max);
        return cursor;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.