在py2neo中搜索节点 [英] Searching for node in py2neo

查看:336
本文介绍了在py2neo中搜索节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使用py2neo搜索具有特定属性的节点? (我有一堆带有{"word":"some word"}的节点,并且我希望能够搜索节点以找到其word属性具有特定值的节点)

Is there a way to search for a node with a specific property using py2neo? (I have a bunch of nodes with {"word": "some word"}, and I want to be able to search through nodes to find a node whose word attribute has a specific value)

推荐答案

我建议您考虑针对这种要求使用索引.您可以根据需要搜索的属性为节点建立索引,然后参考该索引进行搜索.

I suggest that you consider using an index for this kind of requirement. You can index the nodes against the properties you need to search for and then refer to this index for your search.

否则,您将遇到一个性能相对较差的Cypher查询:

Otherwise, you're left with a reasonably non-performant Cypher query:

START n=node(*) 
WHERE n.word! = 'some word' 
RETURN n

我建议您不要使用它,因为它将不得不筛选整个数据库,因此,随着数据库的增长,它会非常耗费资源并且速度很慢.

I'd recommend against using this though as it will have to sift through the entire database and therefore be very resource hungry and slow as your database grows.

这篇关于在py2neo中搜索节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆