无法检索Java Mongodb 2d索引纬度和逻辑度

时间:2017-02-10 06:26:12

标签: java mongodb mongodb-query

DBCollection collection;
public static void main(String[] args) {
MongoClient mongoClient = new MongoClient("localhost" , 27017 );
DB db = mongoClient.getDB("dispatch_location");
DBCollection collection=  db.getCollection("locale");
BasicDBObject point = new BasicDBObject();
collection.createIndex(new BasicDBObject("loc", "2d") );

new QueryBuilder ().near(-88.769896, 34.268103);
QueryBuilder  query = QueryBuilder.start();
    collection.findOne(query);
System.out.println(query);

我得到空指针除了和一位同事告诉我初始化DBCollection我不知道如何初始化

0 个答案:

没有答案