「価格」フィールドが特定の最大値と最小値の間にあるデータを取得したいのですが、Java で以下の構文を使用していますが、機能していないようです。
>
BasicDBObject numeralQ;
List<DBObject> clauses = new ArrayList<DBObject>();
.
.
.
.
numeralQ.put(datafield,new BasicDBObject("$gt", min).append("$lt", max));
clauses.add(numeralQ);
.
.//i also have many other conditions that i want to "OR" them with this condition
.
BasicDBList or = new BasicDBList();
for (DBObject clause : clauses)
or.add(clause);
DBObject query = new BasicDBObject("$or", or);
DBCursor cur = coll.find(query);
while (cur.hasNext()) {
System.out.println(cur.next());
}
私が間違っていることがわかりますか?
- 編集
printing the `query.toString();` results in this string :
{ "$or" : [ { "Price" : { "$gt" : "2" , "$lt" : "1250"}}]}