我正在使用MongoDB和Java驱动程序(http://tinyurl.com/dyjxz8k)。在我的应用程序中,我希望能够给出包含用户搜索词的子字符串的结果。该方法是这样的:如何检索包含搜索词的子字符串的DBObjects?
*索引标识查询=场 * SEARCHTERM的名称=用户搜索内容
private void dbSearch(String searchlabel, String searchTerm){
if(searchTerm != null && (searchTerm.length() > 0)){
DBCollection coll = db.getCollection("MediaCollection");
BasicDBObject query = new BasicDBObject(searchlabel, searchTerm);
DBCursor cursor = coll.find();
cursor = coll.find(query);
try {
while(cursor.hasNext()) {
System.out.println(cursor.next());
//view.showResult(cursor.next());
}
} finally {
cursor.close();
}
}
}
有谁知道,我怎么能解决这个任何想法?在此先感谢=)另外还有一个小问题:如何根据(JLabel in)视图中的表示处理DBObjects?
PLS,显示例如DB结构 – 2013-04-24 06:57:38