【发布时间】:2021-12-30 03:27:19
【问题描述】:
在我目前正在做的 Person,Movie 的 Neo4j 样本数据集中查找 Gene Hackman 电影的导演:
MATCH
(p1:Person{name:"Gene Hackman"})-[:ACTED_IN]->(m:Movie)<-[:DIRECTED]-(p2:Person)
RETURN p1, m, p2
我如何找到由 Gene Hackman 电影的导演执导但没有在电影中与 Gene Hackman 一起表演的演员?
这里是一些示例 json 数据,或者更简单的是在 https://sandbox.neo4j.com/ 处选择“电影”数据集
[
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 97,
"labels": [
"Movie"
],
"properties": {
"tagline": "It's a hell of a thing, killing a man",
"title": "Unforgiven",
"released": 1992
}
},
"p2": {
"identity": 99,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Clint Eastwood"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 97,
"labels": [
"Movie"
],
"properties": {
"tagline": "It's a hell of a thing, killing a man",
"title": "Unforgiven",
"released": 1992
}
},
"p2": {
"identity": 99,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Clint Eastwood"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 97,
"labels": [
"Movie"
],
"properties": {
"tagline": "It's a hell of a thing, killing a man",
"title": "Unforgiven",
"released": 1992
}
},
"p2": {
"identity": 98,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Richard Harris"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 97,
"labels": [
"Movie"
],
"properties": {
"tagline": "It's a hell of a thing, killing a man",
"title": "Unforgiven",
"released": 1992
}
},
"p2": {
"identity": 169,
"labels": [
"Person"
],
"properties": {
"name": "Jessica Thompson"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 95,
"labels": [
"Movie"
],
"properties": {
"tagline": "Come as you are",
"title": "The Birdcage",
"released": 1996
}
},
"p2": {
"identity": 60,
"labels": [
"Person"
],
"properties": {
"born": 1951,
"name": "Robin Williams"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 95,
"labels": [
"Movie"
],
"properties": {
"tagline": "Come as you are",
"title": "The Birdcage",
"released": 1996
}
},
"p2": {
"identity": 96,
"labels": [
"Person"
],
"properties": {
"born": 1931,
"name": "Mike Nichols"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 95,
"labels": [
"Movie"
],
"properties": {
"tagline": "Come as you are",
"title": "The Birdcage",
"released": 1996
}
},
"p2": {
"identity": 80,
"labels": [
"Person"
],
"properties": {
"born": 1956,
"name": "Nathan Lane"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 95,
"labels": [
"Movie"
],
"properties": {
"tagline": "Come as you are",
"title": "The Birdcage",
"released": 1996
}
},
"p2": {
"identity": 169,
"labels": [
"Person"
],
"properties": {
"name": "Jessica Thompson"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 88,
"labels": [
"Person"
],
"properties": {
"born": 1970,
"name": "Brooke Langton"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 170,
"labels": [
"Person"
],
"properties": {
"name": "James Thompson"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 168,
"labels": [
"Person"
],
"properties": {
"name": "Angela Scope"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 169,
"labels": [
"Person"
],
"properties": {
"name": "Jessica Thompson"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 1,
"labels": [
"Person"
],
"properties": {
"born": 1964,
"name": "Keanu Reeves"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 91,
"labels": [
"Person"
],
"properties": {
"born": 1950,
"name": "Howard Deutch"
}
}
},
{
"p1": {
"identity": 89,
"labels": [
"Person"
],
"properties": {
"born": 1930,
"name": "Gene Hackman"
}
},
"m": {
"identity": 87,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"p2": {
"identity": 90,
"labels": [
"Person"
],
"properties": {
"born": 1968,
"name": "Orlando Jones"
}
}
}
]
【问题讨论】:
标签: neo4j cypher graph-databases