运行mongo 2.4 RC并尝试使用文本搜索功能
如何在其他列值上进一步过滤文本搜索命令?
db.Wall.runCommand("text", { search : "Bob"});
答案 0 :(得分:0)
它已记录here。
如文档所示,您需要添加filter
:
db.inventory.runCommand( "text", {
search: "Bob",
filter: { "FavoriteRoom" : "kitchen" }
})
假设你有一个类似的文件:
{
"FavoriteRoom": "kitchen",
"BlockOfText" : "Bob said he'd like to go out for dinner less often."
}
为了获得更好的性能,您需要添加一个索引:
db.inventory.ensureIndex({
"FavoriteRoom": 1,
"BlockOfText": "text"
})