雖然這部作品在蒙戈:與geoQuery不同的值工作在蒙戈,但不是在春天
> db.collection.distinct("key", {"position":{$geoWithin:{$box: [[-6.8, 36.7], [-0.5, 43.8]]}}})
> [ "A", "B" ]
在春天返回一個錯誤
Criteria criteria = Criteria.where("position").within(box);
Query query = new Query();
query.addCriteria(criteria);
List<String> result = mongoOperations.getCollection("collection")
.distinct("key", query.getQueryObject());
java.lang.IllegalArgumentException異常:不能序列類org.springframework.data.mongodb.core.query.GeoCommand at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:299)〜[mongo-java-driver-2.14.3.jar:na] at org.bson .BasicBSONEncoder.putObject(BasicBSONEncoder.java:194)〜[mongo-jav a-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255)〜[mongo-java-driver-2.14.3.jar:na] at org.bson。 BasicBSONEncoder.putObject(BasicBSONEncoder.java:194)〜[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255)〜[mongo-java-driver- 2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194)〜[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(基本BSONEncoder.java:136)〜[mongo-java-driver-2.14.3.jar:na] at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:36)〜[mongo-java-driver-2.14.3。 jar:na] at com.mongodb.OutMessage.putObject(OutMessage.java:289)〜[mongo-java-driver-2.14.3.jar:na] 在com.mongodb.OutMessage.writeQuery(OutMessage.java:211)〜[mongo-java-driver-2.14.3.jar:na] at com.mongodb.OutMessage.query(OutMessage.java:86)〜[mongo -java-driver-2.14.3.jar:na]