我想对大于或等于,小于或等于(我使用java btw)的字段执行查询。换一种说法。 > =和< =。据我所知,mongoDB有$ gte和$ lte操作符,但我找不到合适的语法来使用它。我正在访问的字段是顶级字段。
我设法得到这个工作:
FindIterable<Document> iterable = db.getCollection("1dag").find(new Document("timestamp", new Document("$gt", 1412204098)));
和屁股......
FindIterable<Document> iterable = db.getCollection("1dag").find(new Document("timestamp", new Document("$lt", 1412204098)));
但是你如何将这些彼此?
目前我玩弄这样的说法,但它不工作:
FindIterable<Document> iterable5 = db.getCollection("1dag").find(new Document("timestamp", new Document("$gte", 1412204098).append("timestamp", new Document("$lte",1412204099))));
任何帮助吗?
像魅力一样工作,谢谢! – kongshem