Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重写OrientDB的neo4j查询_Neo4j_Orientdb_Orientdb 2.1_Nosql - Fatal编程技术网

重写OrientDB的neo4j查询

重写OrientDB的neo4j查询,neo4j,orientdb,orientdb-2.1,nosql,Neo4j,Orientdb,Orientdb 2.1,Nosql,我正在测试neo4j与OrientDB graph DBs的性能。我正在使用neo4j网站上提供的MoiveDatabase数据集。我已经按照说明做了: export-graphml -t -o /tmp/out.graphml CREATE DATABASE plocal:/tmp/db/test IMPORT DATABASE /tmp/out.graphml storeVertexIds=true 这里是类输出,所以我想导入是可以的 CLASSES -------------------

我正在测试neo4j与OrientDB graph DBs的性能。我正在使用neo4j网站上提供的MoiveDatabase数据集。我已经按照说明做了:

export-graphml -t -o /tmp/out.graphml
CREATE DATABASE plocal:/tmp/db/test
IMPORT DATABASE /tmp/out.graphml storeVertexIds=true
这里是
输出,所以我想导入是可以的

CLASSES
----------------------+------------------------------------+------------+----------------+
 NAME                 | SUPERCLASS                         | CLUSTERS   | RECORDS        |
----------------------+------------------------------------+------------+----------------+
 ACTS_IN              | [E]                                | 14         |          94700 |
 DIRECTED             | [E]                                | 13         |          11915 |
 E                    |                                    | 10         |              0 |
 FRIEND               | [E]                                | 16         |              6 |
 Movie                | [V]                                | 12         |           6379 |
 OFunction            |                                    | 6          |              0 |
 OIdentity            |                                    | -          |              0 |
 ORestricted          |                                    | -          |              0 |
 ORIDs                |                                    | 8          |              0 |
 ORole                | [OIdentity]                        | 4          |              3 |
 OSchedule            |                                    | 7          |              0 |
 OTriggered           |                                    | -          |              0 |
 OUser                | [OIdentity]                        | 5          |              3 |
 Person               | [V]                                | 11         |          50013 |
 RATED                | [E]                                | 15         |             30 |
 V                    |                                    | 9          |          61752 |
----------------------+------------------------------------+------------+----------------+
 TOTAL = 16                                                                       224801 |
----------------------+------------------------------------+------------+----------------+
但当我尝试执行此查询时:
从电影限制10选择进入()
或从个人限制10选择退出()我没有任何记录。为什么呢

我正试图重写合作者查询:

 MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coActor:Person)
 RETURN coActor.name 
MATCH (tom:Person)-[:ACTED_IN]->(movie1)<-[:ACTED_IN]-(coActor:Person),
(coActor)-[:ACTED_IN]->(movie2)<-[:ACTED_IN]-(coCoActor:Person)
WHERE tom.name = "Tom Hanks" AND   NOT    (tom)-[:ACTED_IN]->(movie2)

RETURN coCoActor.name
MATCH(tom:Person{name:“tom Hanks”})->(电影)(电影1)(电影2)(电影2)
返回coCoActor.name

我应该为此使用
TRAVERSE
吗?

我创建了这个小DB来尝试您的案例:

create class Person extends V
create class Movie extends V
create class acts_In extends E
create class directed extends E
create class friend extends E
create class rated extends E

create property Person.name String
create property Person.surname String
create property Movie.title String

create vertex Person set name="Tom", surname="Hanks"
create vertex Person set name="Robin", surname="Wright"
create vertex Person set name="Helen", surname="Hunt"
create vertex Person set name="Robert", surname="Zemeckis"
create vertex Person set name="Russell", surname="Crowe"
create vertex Person set name="Ben", surname="Affleck"
create vertex Person set name="Kevin", surname="Macdonald"
create vertex Person set name="John"
create vertex Person set name="Mark"
create vertex Person set name="Paul"
create vertex Person set name="Mel", surname="Gibson"
create vertex Person set name="Nancy", surname="Meyers"
create vertex Movie set title="Forrest Gump"
create vertex Movie set title="Cast Away"
create vertex Movie set title="State of Play"
create vertex Movie set title="What Women Want"

create edge acts_In from (select from Person where name="Tom" and surname="Hanks") to (select from Movie where title="Forrest Gump")
create edge acts_In from (select from Person where name="Tom" and surname="Hanks") to (select from Movie where title="Cast Away")
create edge acts_In from (select from Person where name="Robin" and surname="Wright") to (select from Movie where title="Forrest Gump")
create edge acts_In from (select from Person where name="Robin" and surname="Wright") to (select from Movie where title="State of Play")
create edge acts_In from (select from Person where name="Helen" and surname="Hunt") to (select from Movie where title="Cast Away")
create edge acts_In from (select from Person where name="Helen" and surname="Hunt") to (select from Movie where title="What Women Want")
create edge acts_In from (select from Person where name="Mel" and surname="Gibson") to (select from Movie where title="What Women Want")
create edge acts_In from (select from Person where name="Russell" and surname="Crowe") to (select from Movie where title="State of Play")
create edge acts_In from (select from Person where name="Ben" and surname="Affleck") to (select from Movie where title="State of Play")
create edge friend from (select from Person where name="Mel" and surname="Gibson") to (select from Person where name="Helen" and surname="Hunt")
create edge friend from (select from Person where name="Ben" and surname="Affleck") to (select from Person where name="Russell" and surname="Crowe")
create edge directed from (select from Movie where title="What Women Want") to (select from Person where name="Nancy" and surname="Meyers")
create edge directed from (select from Movie where title="Cast Away") to (select from Person where name="Robert" and surname="Zemeckis")
create edge directed from (select from Movie where title="Forrest Gump") to (select from Person where name="Robert" and surname="Zemeckis")
create edge directed from (select from Movie where title="State of Play") to (select from Person where name="Kevin" and surname="Macdonald")
create edge rated from (select from Movie where title="What Women Want") to (select from Person where name="Paul")
create edge rated from (select from Movie where title="Cast Away") to (select from Person where name="John")
create edge rated from (select from Movie where title="Forrest Gump") to (select from Person where name="Mark")
create edge rated from (select from Movie where title="State of Play") to (select from Person where name="John")
第一个查询:找到汤姆·汉克斯的搭档

select distinct(name) as name, distinct(surname) as surname from (select expand(in('acts_In')) from Movie where in('acts_In').name in 'Tom' 
and in('acts_In').surname in 'Hanks') where name<>'Tom' and in('acts_In').surname<>'Hanks'
第二个问题:找到汤姆·汉克斯没有出演过的合作演员

select name, surname from (select expand($ris)
let $a=(select from Person where out('acts_In').size()>0 and name<>'Tom' and surname<>'Hanks'),
    $b=(select from (select expand(in('acts_In')) from Movie where in('acts_In').name in 'Tom' and in('acts_In').surname in 'Hanks') where name<>'Tom' and in('acts_In').surname<>'Hanks'),
    $ris=difference($a,$b))

希望能有所帮助

非常感谢!帮助我弄明白它应该如何工作。我会将答案标记为正确,并请更新第一个查询,您在('acts_in')中有两次
。名称在'Tom'
。我想你应该有姓氏。嗨,谢谢你的投票和指点,我刚刚编辑了我的答案。您有机会尝试这些查询吗?谢谢
select name, surname from (select expand($ris)
let $a=(select from Person where out('acts_In').size()>0 and name<>'Tom' and surname<>'Hanks'),
    $b=(select from (select expand(in('acts_In')) from Movie where in('acts_In').name in 'Tom' and in('acts_In').surname in 'Hanks') where name<>'Tom' and in('acts_In').surname<>'Hanks'),
    $ris=difference($a,$b))
----+------+-------+-------
#   |@CLASS|name   |surname
----+------+-------+-------
0   |null  |Russell|Crowe
1   |null  |Ben    |Affleck
2   |null  |Mel    |Gibson
----+------+-------+-------