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.

How to filter keys in unwind clause

Hi,

I am working with a 3.3.5 community edition of Neo4j.
I would like to display one property out of many in a node.

The following query displays all the properties (tagline, title, released) of the node Movie.

match(p:Movie) WHERE p.released=2004 and p.title contains 'Polar' unwind keys(p) as key return key as keyname, p[key] as value;

Is it possible to display only one property with its keys and values (title for example) like this ?

keyname         value
title                   The Polar Express

Thank you.

Jean-michel, Nemours, France

3 REPLIES 3

yyyguy
Graph Buddy

Hello @alzingrejm1,

Instead of using the keys() function, have you tried to just return the property by name?

Something like this:

MATCH (p:Movie) 
WHERE p.released=2004 
AND p.title contains 'Polar' 
RETURN p.title;

-yyyguy

Hi yyyguy,

Thank you. Yes it works.

MATCH (p:Movie)
WHERE p.released=2004
AND p.title contains 'Polar'
RETURN distinct p.released, p.title;

│"p.released"│"p.title"          │
╞════════════╪═══════════════════╡
│2004        │"The Polar Express"

I am going to test this on production.

Jean-michel

Hi yyyguy,

Following your idea, I managed to get what I need through the following query

match(p:) ... return 'NAME' as key, p.NAME as value;

This way, I get only one line with two columns.

Thank you.

Jean-michel