🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych
Article #194979

Re: Zrozumieć język Cypher

#194979
From: artiun
Date: Mon, 23 May 2016 12:17
86 lines
4763 bytes
W dniu 2016-05-22 o 23:35, Borneq pisze:
> Są przykłady oprogramowania bazy neo4j, zwłaszcza w Javie:
> http://neo4j.com/developer/
> Najpierw mamy listę list i
>               String insertQuery = "UNWIND {pairs} as pair " +
>                "MERGE (p1:Person {name:pair[0]}) " +
>                "MERGE (p2:Person {name:pair[1]}) " +
>                "MERGE (p1)-[:KNOWS]-(p2);";
> Co dokładnie robi?
>
>
> import org.neo4j.driver.v1.*;
> import static org.neo4j.driver.v1.Values.parameters;
>
> import java.util.List;
> import static java.util.Arrays.asList;
> import static java.util.Collections.singletonMap;
>
> public class Social {
>
>     public static void main(String...args) {
>
>         Config noSSL =
> Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
>         Driver driver =
> GraphDatabase.driver("bolt://localhost",AuthTokens.basic("neo4j","test"),noSSL);
> // <password>
>         try (Session session = driver.session()) {
>
>               List data =
>
> asList(asList("Jim","Mike"),asList("Jim","Billy"),asList("Anna","Jim"),
>
> asList("Anna","Mike"),asList("Sally","Anna"),asList("Joe","Sally"),
>               asList("Joe","Bob"),asList("Bob","Sally"));
>
>               String insertQuery = "UNWIND {pairs} as pair " +
>                "MERGE (p1:Person {name:pair[0]}) " +
>                "MERGE (p2:Person {name:pair[1]}) " +
>                "MERGE (p1)-[:KNOWS]-(p2);";
>
>
> session.run(insertQuery,singletonMap("pairs",data)).consume();
>
>                StatementResult result;
>
>                String foafQuery =
>                " MATCH (person:Person)-[:KNOWS]-(friend)-[:KNOWS]-(foaf) "+
>                " WHERE person.name = {name} " +
>                "   AND NOT (person)-[:KNOWS]-(foaf) " +
>                " RETURN foaf.name AS name ";
>                result = session.run(foafQuery, parameters("name","Joe"));
>                while (result.hasNext())
> System.out.println(result.next().get("name"));
>
>                String commonFriendsQuery =
>                "MATCH (user:Person)-[:KNOWS]-(friend)-[:KNOWS]-(foaf:Person)
> " +
>                " WHERE user.name = {from} AND foaf.name = {to} " +
>                " RETURN friend.name AS friend";
>                result = session.run(commonFriendsQuery,
> parameters("from","Joe","to","Sally"));
>                while (result.hasNext())
> System.out.println(result.next().get("friend"));
>
>                String connectingPathsQuery =
>                "MATCH path =
> shortestPath((p1:Person)-[:KNOWS*..6]-(p2:Person)) " +
>                " WHERE p1.name = {from} AND p2.name = {to} " +
>                " RETURN [n IN nodes(path) | n.name] as names";
>                result = session.run(connectingPathsQuery,
> parameters("from","Joe","to","Billy"));
>                while (result.hasNext())
> System.out.println(result.next().get("names"));
>
>         }
>     }
> }
Nie pomyliło Ci się coś?
Nie ta grupa - NTG
A jeśli już coś to nie zajmuj się czymś o ile nie masz o tym pojęcia. Choć 
skromny manual przeczytaj!


-- 
Artur
Technical Details
Message-ID: <5742f5e8$0$641$65785112@news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!weretis.net!feeder4.news.weretis.net!ecngs!testfeeder.ecngs.de!81.171.118.63.MISMATCH!peer03.fr7!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <nht8ni$k96$1@node1.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!weretis.net!feeder4.news.weretis.net!ecngs!testfeeder.ecngs.de!81.171.118.63.MISMATCH!peer03.fr7!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: Zrozumieć język Cypher
Newsgroups: pl.comp.bazy-danych
References: <nht8ni$k96$1@node1.news.atman.pl>
From: artiun <artiun@spam.wp.pl>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAAFXRFWHRDcmVhdGlvbiBUaW1l AAfVBwEUExQxoOF6AAAAB3RJTUUH1QcBFCMjg1qR9gAAAAlwSFlzAAAK8AAACvABQqw0mAAAAAZQ TFRFAAAA////pdmf3QAAAHZJREFUeNpj+A8GDFSjHoOpf8xg6oA8iPrHAJb7wQ+mPtSDqYcQDc+f I1MPW/hB1AMGMPWDGSTY+F+ujvk/QwOjAQ8DP8MBBgEWBkaGj//kVP6z43AEM4QCGtIPpBoYGOfU M/x//IFxDkTJHghVC6F+U9HvQAAATjr8CsUXDxIAAAAASUVORK5CYII=
Date: Mon, 23 May 2016 14:17:15 +0200
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl-PL; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0
MIME-Version: 1.0
In-Reply-To: <nht8ni$k96$1@node1.news.atman.pl>
X-Antivirus: avast! (VPS 160523-0, 2016-05-23), Outbound message
X-Antivirus-Status: Clean
Lines: 86
Message-ID: <5742f5e8$0$641$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 83.22.137.103
X-Trace: 1464006120 unt-rea-b-01.news.neostrada.pl 641 83.22.137.103:9703
X-Complaints-To: abuse@news.neostrada.pl
X-Received-Bytes: 4527
X-Received-Body-CRC: 4281271197
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit