其他分享
首页 > 其他分享> > neo4jGuide简单测试

neo4jGuide简单测试

作者:互联网

电影实例

 

 

neo4j> MATCH (tom {name: "Tom Hanks"}) RETURN tom;
tom
(:Person {born: 1956, name: "Tom Hanks"})
neo4j> MATCH (cloudAtlas {title: "Cloud Atlas"}) RETURN cloudAtlas;
cloudAtlas
(:Movie {tagline: "Everything is connected", title: "Cloud Atlas", released: 2012})
neo4j> MATCH (people:Person) RETURN people.name LIMIT 10;
people.name
"Keanu Reeves"
"Carrie-Anne Moss"
"Laurence Fishburne"
"Hugo Weaving"
"Lilly Wachowski"
"Lana Wachowski"
"Joel Silver"
"Emil Eifrem"
"Charlize Theron"
"Al Pacino"
neo4j> MATCH (nineties:Movie) WHERE nineties.released > 1990 AND
       nineties.released < 2000 RETURN nineties.title;
nineties.title
"The Matrix"
"The Devil's Advocate"
"A Few Good Men"
"As Good as It Gets"
"What Dreams May Come"
"Snow Falling on Cedars"
"You've Got Mail"
"Sleepless in Seattle"
"When Harry Met Sally"
"That Thing You Do"
"The Birdcage"
"Unforgiven"
"Johnny Mnemonic"
"The Green Mile"
"Hoffa"
"Apollo 13"
"Twister"
"Bicentennial Man"
"A League of Their Own"
neo4j>
neo4j> MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies;
tom, tomHanksMovies
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Once in a lifetime you get a chance to do something different.", title: "A League of Their Own", released: 1992})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "A stiff drink. A little mascara. A lot of nerve. Who said they couldn't bring down the Soviet empire.", title: "Charlie Wilson's War", released: 2007})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "This Holiday Season… Believe", title: "The Polar Express", released: 2004})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Houston, we have a problem.", title: "Apollo 13", released: 1995})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "At the edge of the world, his journey begins.", title: "Cast Away", released: 2000})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Walk a mile you'll never forget.", title: "The Green Mile", released: 1999})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Break The Codes", title: "The Da Vinci Code", released: 2006})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Everything is connected", title: "Cloud Atlas", released: 2012})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "In every life there comes a time when that thing you dream becomes that thing you do", title: "That Thing You Do", released: 1996})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "A story of love, lava and burning desire.", title: "Joe Versus the Volcano", released: 1990})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "What if someone you never met, someone you never saw, someone you never knew was the only someone for you?", title: "Sleepless in Seattle", released: 1993})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "At odds in life... in love on-line.", title: "You've Got Mail", released: 1998})
neo4j> MATCH (cloudAtlas {title: "Cloud Atlas"})<-[:DIRECTED]-(directors) RETURN directors.name;
directors.name
"Lana Wachowski"
"Lilly Wachowski"
"Tom Tykwer"
neo4j> MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) RETURN coActors.name;
coActors.name
"Geena Davis"
"Rosie O'Donnell"
"Lori Petty"
"Bill Paxton"
"Madonna"
"Julia Roberts"
"Philip Seymour Hoffman"
"Bill Paxton"
"Ed Harris"
"Kevin Bacon"
"Gary Sinise"
"Helen Hunt"
"Gary Sinise"
"Patricia Clarkson"
"James Cromwell"
"Sam Rockwell"
"Michael Clarke Duncan"
"Bonnie Hunt"
"David Morse"
"Paul Bettany"
"Audrey Tautou"
"Ian McKellen"
"Jim Broadbent"
"Halle Berry"
"Hugo Weaving"
"Liv Tyler"
"Charlize Theron"
"Meg Ryan"
"Nathan Lane"
"Rita Wilson"
"Meg Ryan"
"Victor Garber"
"Bill Pullman"
"Rosie O'Donnell"
"Meg Ryan"
"Dave Chappelle"
"Steve Zahn"
"Greg Kinnear"
"Parker Posey"
neo4j> MATCH (people:Person)-[relatedTo]-(:Movie {title: "Cloud Atlas"})
       RETURN people.name, Type(relatedTo), relatedTo;
people.name, Type(relatedTo), relatedTo
"Jessica Thompson", "REVIEWED", [:REVIEWED {summary: "An amazing journey", rating: 95}]
"Stefan Arndt", "PRODUCED", [:PRODUCED]
"David Mitchell", "WROTE", [:WROTE]
"Lana Wachowski", "DIRECTED", [:DIRECTED]
"Lilly Wachowski", "DIRECTED", [:DIRECTED]
"Tom Tykwer", "DIRECTED", [:DIRECTED]
"Jim Broadbent", "ACTED_IN", [:ACTED_IN {roles: ["Vyvyan Ayrs", "Captain Molyneux", "Timothy Cavendish"]}]
"Halle Berry", "ACTED_IN", [:ACTED_IN {roles: ["Luisa Rey", "Jocasta Ayrs", "Ovid", "Meronym"]}]
"Hugo Weaving", "ACTED_IN", [:ACTED_IN {roles: ["Bill Smoke", "Haskell Moore", "Tadeusz Kesselring", "Nurse Noakes", "Boardman Mephi", "Old Georgie"]}]
"Tom Hanks", "ACTED_IN", [:ACTED_IN {roles: ["Zachry", "Dr. Henry Goose", "Isaac Sachs", "Dermot Hoggins"]}]
neo4j>
neo4j> MATCH (bacon:Person {name:"Kevin Bacon"})-[*1..4]-(hollywood)
       RETURN DISTINCT hollywood;
hollywood
(:Movie {tagline: "In the heart of the nation's capital, in a courthouse of the U.S. government, one man will stop at nothing to keep his honor, and one will stop at nothing to find the truth.", title: "A Few Good Men", released: 1992})
(:Person {born: 1962, name: "Demi Moore"})
(:Person {born: 1962, name: "Tom Cruise"})
(:Movie {tagline: "I feel the need, the need for speed.", title: "Top Gun", released: 1986})
(:Person {born: 1957, name: "Kelly McGillis"})
(:Person {born: 1961, name: "Meg Ryan"})
(:Person {born: 1933, name: "Tom Skerritt"})
(:Person {born: 1962, name: "Anthony Edwards"})
(:Person {born: 1959, name: "Val Kilmer"})
(:Person {born: 1941, name: "Jim Cash"})
(:Person {born: 1944, name: "Tony Scott"})
(:Movie {tagline: "The rest of his life begins now.", title: "Jerry Maguire", released: 2000})
(:Person {born: 1968, name: "Cuba Gooding Jr."})
(:Person {born: 1970, name: "Jay Mohr"})
(:Person {born: 1974, name: "Jerry O'Connell"})
(:Person {born: 1962, name: "Kelly Preston"})
(:Person {born: 1969, name: "Renee Zellweger"})
(:Person {born: 1957, name: "Cameron Crowe"})
(:Person {born: 1996, name: "Jonathan Lipnicki"})
(:Person {born: 1971, name: "Regina King"})
(:Person {born: 1961, name: "Bonnie Hunt"})
(:Person {name: "Jessica Thompson"})
(:Person {born: 1937, name: "Jack Nicholson"})
(:Movie {tagline: "A comedy from the heart that goes for the throat.", title: "As Good as It Gets", released: 1997})
(:Person {born: 1963, name: "Greg Kinnear"})
(:Person {born: 1940, name: "James L. Brooks"})
(:Person {born: 1963, name: "Helen Hunt"})
(:Movie {tagline: "He didn't want law. He wanted justice.", title: "Hoffa", released: 1992})
(:Person {born: 1943, name: "J.T. Walsh"})
(:Person {born: 1944, name: "Danny DeVito"})
(:Person {born: 1965, name: "John C. Reilly"})
(:Movie {tagline: "If he's crazy, what does that make you?", title: "One Flew Over the Cuckoo's Nest", released: 1975})
(:Person {born: 1932, name: "Milos Forman"})
(:Movie {title: "Something's Gotta Give", released: 2003})
(:Person {born: 1949, name: "Nancy Meyers"})
(:Person {born: 1964, name: "Keanu Reeves"})
(:Person {born: 1946, name: "Diane Keaton"})
(:Movie {tagline: "After life there is more. The end is just the beginning.", title: "What Dreams May Come", released: 1998})
(:Person {born: 1951, name: "Robin Williams"})
(:Person {born: 1956, name: "Vincent Ward"})
(:Person {born: 1960, name: "Annabella Sciorra"})
(:Person {born: 1942, name: "Werner Herzog"})
(:Person {born: 1929, name: "Max von Sydow"})
(:Person {born: 1957, name: "Kevin Pollak"})
(:Person {born: 1966, name: "Kiefer Sutherland"})
(:Movie {tagline: "For some, it's the last real taste of innocence, and the first real taste of life. But for everyone, it's the time that memories are made of.", title: "Stand By Me", released: 1986})
(:Person {born: 1971, name: "Corey Feldman"})
(:Person {born: 1966, name: "John Cusack"})
(:Person {born: 1972, name: "Wil Wheaton"})
(:Person {born: 1970, name: "River Phoenix"})
(:Person {born: 1942, name: "Marshall Bell"})
(:Person {born: 1947, name: "Rob Reiner"})
(:Person {born: 1971, name: "Noah Wyle"})
(:Person {born: 1948, name: "Christopher Guest"})
(:Person {born: 1961, name: "Aaron Sorkin"})
(:Person {born: 1967, name: "James Marshall"})
(:Movie {tagline: "Freedom! Forever!", title: "V for Vendetta", released: 2006})
(:Person {born: 1960, name: "Hugo Weaving"})
(:Person {born: 1981, name: "Natalie Portman"})
(:Person {born: 1946, name: "Stephen Rea"})
(:Person {born: 1967, name: "Lilly Wachowski"})
(:Person {born: 1967, name: "Ben Miles"})
(:Person {born: 1940, name: "John Hurt"})
(:Person {born: 1965, name: "Lana Wachowski"})
(:Person {born: 1952, name: "Joel Silver"})
(:Movie {tagline: "Prepare to enter a secret world of assassins", title: "Ninja Assassin", released: 2009})
(:Person {born: 1971, name: "Rick Yune"})
(:Person {born: 1982, name: "Rain"})
(:Person {name: "Naomie Harris"})
(:Movie {tagline: "At odds in life... in love on-line.", title: "When Harry Met Sally", released: 1998})
(:Person {born: 1956, name: "Carrie Fisher"})
(:Person {born: 1949, name: "Bruno Kirby"})
(:Person {born: 1948, name: "Billy Crystal"})
(:Person {born: 1941, name: "Nora Ephron"})
(:Movie {tagline: "400 million people were waiting for the truth.", title: "Frost/Nixon", released: 2008})
(:Person {born: 1968, name: "Sam Rockwell"})
(:Movie {tagline: "Walk a mile you'll never forget.", title: "The Green Mile", released: 1999})
(:Person {born: 1953, name: "David Morse"})
(:Person {born: 1956, name: "Tom Hanks"})
(:Person {born: 1957, name: "Michael Clarke Duncan"})
(:Person {born: 1959, name: "Frank Darabont"})
(:Person {born: 1940, name: "James Cromwell"})
(:Person {born: 1959, name: "Patricia Clarkson"})
(:Person {born: 1955, name: "Gary Sinise"})
(:Person {born: 1960, name: "Oliver Platt"})
(:Movie {tagline: "One robot's 200 year journey to become an ordinary man.", title: "Bicentennial Man", released: 1999})
(:Person {born: 1958, name: "Chris Columbus"})
(:Person {born: 1954, name: "Ron Howard"})
(:Movie {tagline: "Break The Codes", title: "The Da Vinci Code", released: 2006})
(:Person {born: 1939, name: "Ian McKellen"})
(:Person {born: 1976, name: "Audrey Tautou"})
(:Person {born: 1971, name: "Paul Bettany"})
(:Person {name: "James Thompson"})
(:Movie {tagline: "Houston, we have a problem.", title: "Apollo 13", released: 1995})
(:Person {born: 1958, name: "Kevin Bacon"})
(:Person {born: 1950, name: "Ed Harris"})
(:Person {born: 1955, name: "Bill Paxton"})
(:Person {born: 1938, name: "Frank Langella"})
(:Person {born: 1969, name: "Michael Sheen"})
(:Movie {tagline: "At odds in life... in love on-line.", title: "You've Got Mail", released: 1998})
(:Person {born: 1968, name: "Parker Posey"})
(:Person {born: 1967, name: "Steve Zahn"})
(:Person {born: 1973, name: "Dave Chappelle"})
(:Movie {tagline: "What if someone you never met, someone you never saw, someone you never knew was the only someone for you?", title: "Sleepless in Seattle", released: 1993})
(:Person {born: 1962, name: "Rosie O'Donnell"})
(:Person {born: 1953, name: "Bill Pullman"})
(:Person {born: 1949, name: "Victor Garber"})
(:Person {born: 1956, name: "Rita Wilson"})
(:Movie {tagline: "A story of love, lava and burning desire.", title: "Joe Versus the Volcano", released: 1990})
(:Person {born: 1956, name: "Nathan Lane"})
(:Person {born: 1950, name: "John Patrick Stanley"})
(:Movie {tagline: "In every life there comes a time when that thing you dream becomes that thing you do", title: "That Thing You Do", released: 1996})
(:Person {born: 1975, name: "Charlize Theron"})
(:Person {born: 1977, name: "Liv Tyler"})
(:Movie {tagline: "Everything is connected", title: "Cloud Atlas", released: 2012})
(:Person {born: 1966, name: "Halle Berry"})
(:Person {born: 1949, name: "Jim Broadbent"})
(:Person {born: 1965, name: "Tom Tykwer"})
(:Person {born: 1969, name: "David Mitchell"})
(:Person {born: 1961, name: "Stefan Arndt"})
(:Movie {tagline: "At the edge of the world, his journey begins.", title: "Cast Away", released: 2000})
(:Person {born: 1951, name: "Robert Zemeckis"})
(:Movie {tagline: "This Holiday Season… Believe", title: "The Polar Express", released: 2004})
(:Movie {tagline: "A stiff drink. A little mascara. A lot of nerve. Who said they couldn't bring down the Soviet empire.", title: "Charlie Wilson's War", released: 2007})
(:Person {born: 1931, name: "Mike Nichols"})
(:Person {born: 1967, name: "Philip Seymour Hoffman"})
(:Person {born: 1967, name: "Julia Roberts"})
(:Movie {tagline: "Once in a lifetime you get a chance to do something different.", title: "A League of Their Own", released: 1992})
(:Person {born: 1943, name: "Penny Marshall"})
(:Person {born: 1954, name: "Madonna"})
(:Person {born: 1963, name: "Lori Petty"})
(:Person {born: 1956, name: "Geena Davis"})
(:Movie {tagline: "Don't Breathe. Don't Look Back.", title: "Twister", released: 1996})
(:Person {born: 1954, name: "Zach Grenier"})
(:Person {born: 1943, name: "Jan de Bont"})
neo4j> MATCH p=shortestPath(
         (bacon:Person {name:"Kevin Bacon"})-[*]-(meg:Person {name:"Meg Ryan"})
       )
       RETURN p;
p
(:Person {born: 1958, name: "Kevin Bacon"})-[:ACTED_IN {roles: ["Jack Swigert"]}]->(:Movie {tagline: "Houston, we have a problem.", title: "Apollo 13", released: 1995})<-[:ACTED_IN {roles: ["Jim Lovell"]}]-(:Person {born: 1956, name: "Tom Hanks"})-[:ACTED_IN {roles: ["Joe Banks"]}]->(:Movie {tagline: "A story of love, lava and burning desire.", title: "Joe Versus the Volcano", released: 1990})<-[:ACTED_IN {roles: ["DeDe", "Angelica Graynamore", "Patricia Graynamore"]}]-(:Person {born: 1961, name: "Meg Ryan"})
neo4j>
neo4j> MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors),
             (coActors)-[:ACTED_IN]->(m2)<-[:ACTED_IN]-(cocoActors)
       WHERE NOT (tom)-[:ACTED_IN]->(m2)
       RETURN cocoActors.name AS Recommended, count(*) AS Strength ORDER BY Strength DESC;
Recommended, Strength
"Tom Cruise", 5
"Zach Grenier", 5
"Helen Hunt", 4
"Cuba Gooding Jr.", 4
"Keanu Reeves", 4
"Tom Skerritt", 3
"Carrie-Anne Moss", 3
"Val Kilmer", 3
"Bruno Kirby", 3
"Philip Seymour Hoffman", 3
"Billy Crystal", 3
"Carrie Fisher", 3
"Kelly McGillis", 3
"Anthony Edwards", 3
"Laurence Fishburne", 3
"Jack Nicholson", 3
"Bill Paxton", 2
"Michael Sheen", 2
"Frank Langella", 2
"Oliver Platt", 2
"Emil Eifrem", 1
"Sam Rockwell", 1
"Jay Mohr", 1
"Stephen Rea", 1
"Ben Miles", 1
"Renee Zellweger", 1
"Regina King", 1
"Kevin Pollak", 1
"Natalie Portman", 1
"Rick Yune", 1
"Gene Hackman", 1
"J.T. Walsh", 1
"Christopher Guest", 1
"Al Pacino", 1
"Marshall Bell", 1
"Ethan Hawke", 1
"Kelly Preston", 1
"Jonathan Lipnicki", 1
"Greg Kinnear", 1
"Demi Moore", 1
"James Marshall", 1
"Kevin Bacon", 1
"Jerry O'Connell", 1
"Max von Sydow", 1
"Noah Wyle", 1
"Kiefer Sutherland", 1
"Aaron Sorkin", 1
"John Hurt", 1
"Christian Bale", 1
"Robin Williams", 1
neo4j> MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors),
             (coActors)-[:ACTED_IN]->(m2)<-[:ACTED_IN]-(cruise:Person {name:"Tom Cruise"})
       RETURN tom, m, coActors, m2, cruise;
tom, m, coActors, m2, cruise
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Houston, we have a problem.", title: "Apollo 13", released: 1995}), (:Person {born: 1958, name: "Kevin Bacon"}), (:Movie {tagline: "In the heart of the nation's capital, in a courthouse of the U.S. government, one man will stop at nothing to keep his honor, and one will stop at nothing to find the truth.", title: "A Few Good Men", released: 1992}), (:Person {born: 1962, name: "Tom Cruise"})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "Walk a mile you'll never forget.", title: "The Green Mile", released: 1999}), (:Person {born: 1961, name: "Bonnie Hunt"}), (:Movie {tagline: "The rest of his life begins now.", title: "Jerry Maguire", released: 2000}), (:Person {born: 1962, name: "Tom Cruise"})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "A story of love, lava and burning desire.", title: "Joe Versus the Volcano", released: 1990}), (:Person {born: 1961, name: "Meg Ryan"}), (:Movie {tagline: "I feel the need, the need for speed.", title: "Top Gun", released: 1986}), (:Person {born: 1962, name: "Tom Cruise"})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "What if someone you never met, someone you never saw, someone you never knew was the only someone for you?", title: "Sleepless in Seattle", released: 1993}), (:Person {born: 1961, name: "Meg Ryan"}), (:Movie {tagline: "I feel the need, the need for speed.", title: "Top Gun", released: 1986}), (:Person {born: 1962, name: "Tom Cruise"})
(:Person {born: 1956, name: "Tom Hanks"}), (:Movie {tagline: "At odds in life... in love on-line.", title: "You've Got Mail", released: 1998}), (:Person {born: 1961, name: "Meg Ryan"}), (:Movie {tagline: "I feel the need, the need for speed.", title: "Top Gun", released: 1986}), (:Person {born: 1962, name: "Tom Cruise"})
neo4j>
neo4j> MATCH (a:Person),(m:Movie) OPTIONAL MATCH (a)-[r1]-(), (m)-[r2]-() DELETE a,r1,m,r2;
Deleted 171 nodes, Deleted 253 relationships
neo4j> MATCH (n) RETURN n;
n
(:student {name: "wwl"})
(:student {name: "jj"})
(:student {name: "xld"})
neo4j>

 

标签:name,neo4jGuide,Person,Movie,title,born,测试,简单,released
来源: https://blog.csdn.net/qq_42304949/article/details/90348518