0

查看 GrandStack 电影研讨会的示例https://github.com/grand-stack/grand-stack-movies-workshop/blob/master/neo4j-database/answers.md

此处为推荐电影提出的查询

MATCH (m:Movie) WHERE m.movieId = $movieId
MATCH (m)-[:IN_GENRE]->(g:Genre)<-[:IN_GENRE]-(movie:Movie)
WITH m, movie, COUNT(*) AS genreOverlap
MATCH (m)<-[:RATED]-(:User)-[:RATED]->(movie:Movie)
WITH movie,genreOverlap, COUNT(*) AS userRatedScore
RETURN movie ORDER BY (0.9 * genreOverlap) + (0.1 * userRatedScore)  DESC LIMIT 3

这个查询会不会有偏见,因为它只会为与 ID 为 $movieId 的电影共享至少一种类型的电影计算 userRatedScore?

一个独立计算两个分数的重写查询看起来如何,这意味着它仍然会计算给定电影的 userRatedScore,即使它不与 ID 为 $movieId 的电影共享流派

4

1 回答 1

0

如果您想忽略 Genre 提供的权重,那么您可以删除查找它的查询部分,例如:

MATCH (m:Movie) WHERE m.movieId = $movieId, (m)<-[:RATED]-(:User)-[:RATED]->(movie:Movie)
WITH movie, COUNT(*) AS userRatedScore
RETURN movie ORDER BY (0.1 * userRatedScore)  DESC LIMIT 3
于 2019-11-01T10:36:38.317 回答