我正在使用以下内容从索引中获取节点:
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
中的整数。
我可以通过正则表达式获得它,但这肯定不是最好的方法吗?
您可以使用"阶段 2"API 查找它,如下所示;
n = Neography::Node.find('nodes_index', 'type', 'repo')
n.neo_id # 12