我有一个MongoDB,我可以查询数据库'国家',工作正常。但是我现在也想用自由文本搜索字段'标题'。与在SQL中一样,WHERE标题LIKE'%title%'MongoDB数据库,查询类似
BasicDBObject query = new BasicDBObject();
query.put("country", country);
query.put("title", %title%);
DBCursor cursor = collection.find(query);
我该如何对MongoDB执行此操作?
感谢您的任何帮助!
重复的http://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like – Xaerxess
我怎么会把这个到我的代码? BasicDBObject query = new BasicDBObject(); query.put(“country”,country); query.put(“title”,/ title/i); ??????????? –