我会解释:我有这个功能
function (doc) {
if(doc.MovieId == "1721")
emit(doc.Rating, 1);
}
但它返回给我一些不相关的文件(例如他们没有评级字段)。我的文档 _id 由 partitionName:id 组成,所以我想这样做,if(doc.MovieId == "1721" && doc._id.contains("ratings"){...}
但它不起作用。有没有办法做到这一点?
-----编辑 1----- 圆圈中的文档不相关。您需要 JSON 文档的架构吗?
-----编辑 2----- 以下文件不相关 1。
{
"_id": "movies : 1721",
"_rev": "1-d7e0e3c8152d6978073d280e0aef7457",
"MovieId": "1721",
"Title": "Titanic (1997)",
"Genres": [
"Drama",
"Romance"
]
}
2.
{
"_id": "tags : 1490",
"_rev": "1-14c20c9cfb3ee1964a298777f80333d5",
"MovieId": "1721",
"UserId": "474",
"Tag": "shipwreck",
"Timestamp": "1138031879"
}
3.
{
"_id": "tags : 2791",
"_rev": "1-e4d6c9573fcdae726a69d5fc6255de27",
"MovieId": "1721",
"UserId": "537",
"Tag": "romance",
"Timestamp": "1424141922"
}
像这样的文档是相关的:
{
"_id": "ratings : 31662",
"_rev": "1-446665286337faaf51e23e40b527ec2d",
"MovieId": "1721",
"UserId": "219",
"Rating": "0.5",
"Timestamp": "1214043346"
}