cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using where and Contains to set anchor for path

We have a node in the database that contains the text 'SSN". We can find that node easy enough.

Match (a) where a.text contains 'SSN' return a;

But now I need to trace its path from the node with SSN, all the way back to the root. (inode:0)

How do I combine a where contains in the qualifier for a.

1 ACCEPTED SOLUTION

correct. just add a 'set a.??????`

but why are you encoutering failures?

View solution in original post

10 REPLIES 10

Match p=(     (a)<-[*]-(n {inode:0})   ) where a.text contains 'SSN' return p

Surprisingly fast. Sorry it took me a bit to test. So if I want to update a property on a, can I just replace the return with a set ? Thanks again !

correct. just add a 'set a.??????`

but why are you encoutering failures?

Lol. Not your problem. We have been having rolling blackouts and -3F temperatures here. So it just took me longer than usual to set and test it. Solution was perfect.

Got a chance to test it and it does work perfectly. I do have a followup question.

p is a set of nodes. I want to set a flag on all of the p nodes that says they were part of the issue. So something along the lines of p.flag = true

How would I integrate that ? using just a or n gives me end points but nothing in between. Do I need to unwind p ?

clem
Graph Steward

For performance reasons, you may want to make SSN a separate property.

The condition where a.text contains 'SSN' is expensive and may not scale well as your DB grows.

A more complete answer -

We are using this as a back stop. In most cases we do define the attributes separately, but the users always have one more thing that they want and if we add the search feature, it buys us time. These are run in batch, so if it takes 10-15 mins, thats annoying but not fatal. No human is waiting for it then.

We do worry about scaling so I appreciate the thought. Speed is always good.
Thanks

Clem - Can't be done that way for a variety of reasons and the DB is already over 3m nodes. It will probably top out at 30m. Thanks

I'm not sure what you mean.... If you have 3m nodes, then doing CONTAINS could be very expensive depending on how many of those you do...

One trick that could make things go faster, is use SSN as a Label instead of imbedded in a property string.

something like

CREATE(node:Person:SSN)

This would be especially good if very few nodes have SSN property, then finding them will be fast.

You can set (and remove) Labels easily.

Thanks. Appreciate the advice.