3

我正在使用以下内容从索引中获取节点:

neo.get_node_index('nodes_index', 'type', 'repo')

哪个工作正常。但是,返回的数据是一个 Hash 对象,如下所示:

> {"indexed"=>"http://localhost:7474/db/data/index/node/nodes_index/type/repo/12", "outgoing_relationships"=>"http://localhost:7474/db/data/node/12/relationships/out",
> "data"=>{"name"=>"irc-logs"},
> "traverse"=>"http://localhost:7474/db/data/node/12/traverse/{returnType}",
> "all_typed_relationships"=>"http://localhost:7474/db/data/node/12/relationships/all/{-list|&|types}",
> "property"=>"http://localhost:7474/db/data/node/12/properties/{key}",
> "self"=>"http://localhost:7474/db/data/node/12",
> "properties"=>"http://localhost:7474/db/data/node/12/properties",
> "outgoing_typed_relationships"=>"http://localhost:7474/db/data/node/12/relationships/out/{-list|&|types}",
> "incoming_relationships"=>"http://localhost:7474/db/data/node/12/relationships/in",
> "extensions"=>{},
> "create_relationship"=>"http://localhost:7474/db/data/node/12/relationships", "paged_traverse"=>"http://localhost:7474/db/data/node/12/paged/traverse/{returnType}{?pageSize,leaseTime}",
> "all_relationships"=>"http://localhost:7474/db/data/node/12/relationships/all",
> "incoming_typed_relationships"=>"http://localhost:7474/db/data/node/12/relationships/in/{-list|&|types}"}

我希望返回实际的节点对象,或者能够轻松检索 id。id,我指的是里面的整数http://localhost:7474/db/data/node/12

我可以通过正则表达式得到它,但这肯定不是最好的方法?

4

1 回答 1

2

您可以使用“第 2 阶段”API来找到它,如下所示;

n = Neography::Node.find('nodes_index', 'type', 'repo')

n.neo_id # 12

于 2013-11-06T12:27:59.000 回答