Searching for node in py2neo

2019-07-19 18:11发布

问题:

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)

回答1:

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.

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.



标签: neo4j py2neo