cancel
Showing results for 
Search instead for 
Did you mean: 

Return except specific property

ri8ika
Graph Voyager

Is there no way to return every property except one?

For eg. the following will return all properties:

MATCH (n:Node)
RETURN n

Now, what I want/suggest to provide feature something like below if there's no way to achieve as far as current system:

MATCH (n:Node)
RETURN n {.*, !except:specific} // exclamation, otherwise it seems to be included property
7 REPLIES 7

This is something we'd love to include later, but in the meantime you can use some map functions from APOC Procedures for a workaround:

MATCH (n:Node)
RETURN apoc.map.removeKey(n {.*}, 'specific') as propsWithoutKey

Sadly, I am not using APOC.

In that case I don't believe there are any workarounds here for the time being, unless you want to write the equivalent as your own stored procedure and deploy it.

This is very close to what you need, except it returns an array and not a map:

MATCH (n:Node)
RETURN [x in keys(n) WHERE not x in ["bad1"]| [x, n[x] ] ]

Cypher doesn't have a way to create maps with dynamic keys, so either APOC or array as workarounds.

This is something we'd love to include later...

Please reply here whenever Cypher itself will include the feature. I'll be waiting for long to get this feature...

We have the request in our backlog, but keep in mind this is subject to prioritization, and there is a lot on our plates for 4.0. We can't offer any guarantees on when this may make it into the product.

I hope it will be done at least in 1 year.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.