节点属性上的Neo4j SPARQL插件

时间:2014-06-09 08:27:00

标签: neo4j cypher sparql

我已经使用了SPARQL插件(SPARQL 1.0)获得了Neo4j 1.9.7。

我已将.nt文件导入数据库,创建了相应的节点和关系。 每个节点都有一个属性值,该值是节点的名称。 是否可以从插件中执行SPARQL查询,该查询找到具有特定"值的节点" ?

e.g。节点(2)---值:BusinessProcess1

我的目标是在SPARQL中进行类似于Cypher中的查询:

start n=node(*)
match (n)-[r]-(x)
where n.value="http://neo4j.org#BusinessProcess1"
return n,n.value, x, x.value, type(r)

这个查询给我一个这样的输出:

      n              n.value                      x                   x.value              type(r)
    Node 2  "http://neo4j.org#BusinessProcess1" Node 5  "http://neo4j.org#ApplicationProcess2"  "http://neo4j.org#RUN"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 3  "http://neo4j.org#ApplicationProcess3"  "http://neo4j.org#RUN"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 10 "http://neo4j.org#ApplicationProcess39" "http://neo4j.org#COMPOSED_BY"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 5  "http://neo4j.org#ApplicationProcess2"  "http://neo4j.org#COMPOSED_BY"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 157    "http://neo4j.org#ApplicationProcess12" "http://neo4j.org#COMPOSED_BY"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 192    "http://neo4j.org#ApplicationProcess1"  "http://neo4j.org#COMPOSED_BY"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 45 "http://neo4j.org#ApplicationProcess7"  "http://neo4j.org#COMPOSED_BY"
    Node 2  "http://neo4j.org#BusinessProcess1" Node 80 "http://neo4j.org#ApplicationProcess34" "http://neo4j.org#COMPOSED_BY"

可以这样做吗?

编辑:这是我的数据集上的探索性查询的输出

[ {
  "s" : "http://neo4j.org#BusinessProcess1",
  "p" : "http://neo4j.org#RUN",
  "o" : "http://neo4j.org#ApplicationProcess3"
}, {
  "s" : "http://neo4j.org#ApplicationProcess3",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database2"
}, {
  "s" : "http://neo4j.org#BusinessProcess1",
  "p" : "http://neo4j.org#RUN",
  "o" : "http://neo4j.org#ApplicationProcess2"
}, {
  "s" : "http://neo4j.org#ApplicationProcess24",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database235"
}, {
  "s" : "http://neo4j.org#BusinessProcess41",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess39"
}, {
  "s" : "http://neo4j.org#ApplicationProcess14",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database851"
}, {
  "s" : "http://neo4j.org#BusinessProcess45",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess5"
}, {
  "s" : "http://neo4j.org#BusinessProcess5",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess27"
}, {
  "s" : "http://neo4j.org#ApplicationProcess36",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database200"
}, {
  "s" : "http://neo4j.org#ApplicationProcess25",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database261"
}, {
  "s" : "http://neo4j.org#ApplicationProcess9",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database842"
}, {
  "s" : "http://neo4j.org#ApplicationProcess2",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database919"
}, {
  "s" : "http://neo4j.org#BusinessProcess20",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess2"
}, {
  "s" : "http://neo4j.org#ApplicationProcess38",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database528"
}, {
  "s" : "http://neo4j.org#BusinessProcess7",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess8"
}, {
  "s" : "http://neo4j.org#ApplicationProcess9",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database626"
}, {
  "s" : "http://neo4j.org#ApplicationProcess31",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database825"
}, {
  "s" : "http://neo4j.org#ApplicationProcess39",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database214"
}, {
  "s" : "http://neo4j.org#ApplicationProcess2",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database89"
}, {
  "s" : "http://neo4j.org#ApplicationProcess39",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database138"
}, {
  "s" : "http://neo4j.org#ApplicationProcess35",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database369"
}, {
  "s" : "http://neo4j.org#ApplicationProcess35",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database91"
}, {
  "s" : "http://neo4j.org#ApplicationProcess26",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database85"
}, {
  "s" : "http://neo4j.org#BusinessProcess9",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess3"
}, {
  "s" : "http://neo4j.org#ApplicationProcess4",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database513"
}, {
  "s" : "http://neo4j.org#BusinessProcess3",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess19"
}, {
  "s" : "http://neo4j.org#ApplicationProcess7",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database903"
}, {
  "s" : "http://neo4j.org#ApplicationProcess28",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database130"
}, {
  "s" : "http://neo4j.org#BusinessProcess19",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess39"
}, {
  "s" : "http://neo4j.org#ApplicationProcess25",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database139"
}, {
  "s" : "http://neo4j.org#BusinessProcess34",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess14"
}, {
  "s" : "http://neo4j.org#ApplicationProcess36",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database866"
}, {
  "s" : "http://neo4j.org#BusinessProcess32",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess20"
}, {
  "s" : "http://neo4j.org#ApplicationProcess11",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database295"
}, {
  "s" : "http://neo4j.org#BusinessProcess35",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess21"
}, {
  "s" : "http://neo4j.org#ApplicationProcess21",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database518"
}, {
  "s" : "http://neo4j.org#ApplicationProcess19",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database311"
}, {
  "s" : "http://neo4j.org#ApplicationProcess11",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database784"
}, {
  "s" : "http://neo4j.org#ApplicationProcess18",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database166"
}, {
  "s" : "http://neo4j.org#ApplicationProcess16",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database254"
}, {
  "s" : "http://neo4j.org#BusinessProcess12",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess13"
}, {
  "s" : "http://neo4j.org#ApplicationProcess25",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database428"
}, {
  "s" : "http://neo4j.org#ApplicationProcess30",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database18"
}, {
  "s" : "http://neo4j.org#ApplicationProcess23",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database703"
}, {
  "s" : "http://neo4j.org#ApplicationProcess38",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database330"
}, {
  "s" : "http://neo4j.org#ApplicationProcess8",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database238"
}, {
  "s" : "http://neo4j.org#BusinessProcess36",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess5"
}, {
  "s" : "http://neo4j.org#BusinessProcess3",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess27"
}, {
  "s" : "http://neo4j.org#BusinessProcess12",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess7"
}, {
  "s" : "http://neo4j.org#ApplicationProcess0",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database48"
}, {
  "s" : "http://neo4j.org#ApplicationProcess26",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database194"
}, {
  "s" : "http://neo4j.org#BusinessProcess49",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess34"
}, {
  "s" : "http://neo4j.org#BusinessProcess12",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess30"
}, {
  "s" : "http://neo4j.org#ApplicationProcess32",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database506"
}, {
  "s" : "http://neo4j.org#ApplicationProcess26",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database351"
}, {
  "s" : "http://neo4j.org#ApplicationProcess31",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database818"
}, {
  "s" : "http://neo4j.org#BusinessProcess48",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess22"
}, {
  "s" : "http://neo4j.org#BusinessProcess7",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess22"
}, {
  "s" : "http://neo4j.org#BusinessProcess50",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess11"
}, {
  "s" : "http://neo4j.org#ApplicationProcess37",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database91"
}, {
  "s" : "http://neo4j.org#ApplicationProcess15",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database314"
}, {
  "s" : "http://neo4j.org#ApplicationProcess4",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database849"
}, {
  "s" : "http://neo4j.org#ApplicationProcess0",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database487"
}, {
  "s" : "http://neo4j.org#BusinessProcess7",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess14"
}, {
  "s" : "http://neo4j.org#ApplicationProcess5",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database187"
}, {
  "s" : "http://neo4j.org#ApplicationProcess34",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database330"
}, {
  "s" : "http://neo4j.org#ApplicationProcess23",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database131"
}, {
  "s" : "http://neo4j.org#BusinessProcess43",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess6"
}, {
  "s" : "http://neo4j.org#ApplicationProcess21",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database86"
}, {
  "s" : "http://neo4j.org#BusinessProcess37",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess30"
}, {
  "s" : "http://neo4j.org#BusinessProcess38",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess23"
}, {
  "s" : "http://neo4j.org#ApplicationProcess11",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database622"
}, {
  "s" : "http://neo4j.org#ApplicationProcess7",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database9"
}, {
  "s" : "http://neo4j.org#BusinessProcess30",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess36"
}, {
  "s" : "http://neo4j.org#BusinessProcess7",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess24"
}, {
  "s" : "http://neo4j.org#BusinessProcess29",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess38"
}, {
  "s" : "http://neo4j.org#ApplicationProcess35",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database109"
}, {
  "s" : "http://neo4j.org#ApplicationProcess38",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database51"
}, {
  "s" : "http://neo4j.org#BusinessProcess4",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess26"
}, {
  "s" : "http://neo4j.org#ApplicationProcess16",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database698"
}, {
  "s" : "http://neo4j.org#BusinessProcess43",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess32"
}, {
  "s" : "http://neo4j.org#ApplicationProcess17",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database496"
}, {
  "s" : "http://neo4j.org#BusinessProcess14",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess35"
}, {
  "s" : "http://neo4j.org#BusinessProcess37",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess21"
}, {
  "s" : "http://neo4j.org#ApplicationProcess38",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database603"
}, {
  "s" : "http://neo4j.org#ApplicationProcess18",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database145"
}, {
  "s" : "http://neo4j.org#BusinessProcess19",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess26"
}, {
  "s" : "http://neo4j.org#ApplicationProcess16",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database282"
}, {
  "s" : "http://neo4j.org#BusinessProcess43",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess20"
}, {
  "s" : "http://neo4j.org#BusinessProcess23",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess18"
}, {
  "s" : "http://neo4j.org#ApplicationProcess29",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database66"
}, {
  "s" : "http://neo4j.org#ApplicationProcess28",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database94"
}, {
  "s" : "http://neo4j.org#ApplicationProcess18",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database848"
}, {
  "s" : "http://neo4j.org#BusinessProcess21",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess39"
}, {
  "s" : "http://neo4j.org#BusinessProcess42",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess37"
}, {
  "s" : "http://neo4j.org#ApplicationProcess37",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database850"
}, {
  "s" : "http://neo4j.org#BusinessProcess41",
  "p" : "http://neo4j.org#COMPOSED_BY",
  "o" : "http://neo4j.org#ApplicationProcess31"
}, {
  "s" : "http://neo4j.org#ApplicationProcess6",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database443"
}, {
  "s" : "http://neo4j.org#ApplicationProcess20",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database913"
}, {
  "s" : "http://neo4j.org#ApplicationProcess22",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database772"
} ]

1 个答案:

答案 0 :(得分:0)

这是相当愚蠢的我可以直接使用价值广告做这样的查询

 "query":"PREFIX bus:<http://neo4j.org#BusinessProcess> SELECT * WHERE {bus:1 ?p ?o}"