这就是我如何创建具有不同权重的索引蒙戈外壳.
db.blog.ensureIndex(
{
content: "text",
keywords: "text",
about: "text"
},
{
weights: {
content: 10,
keywords: 5,
},
name: "TextIndex"
}
)
这就是我使用以下方法为字段创建索引的方法Java.
BasicDBObject index = new BasicDBObject();
index.put("content", "text");
index.put("keywords", "text");
index.put("about", "text");
collection.ensureIndex( index, "TextIndex");
如何使用分配权重Java
driver?
为索引字段分配权重Java
:
BasicDBObject index = new BasicDBObject();
index.put("content", "text");
index.put("keywords", "text");
index.put("about", "text");
BasicDBObject weights = new BasicDBObject("content", 10).append("keyword", 5);
BasicDBObject options = new BasicDBObject("weights", weights).append("name", "TextIndex");
collection.createIndex(index,options);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)