Filter a list of properties in a selected node in Ne04j

I am new to Neo4j and have the following node structure in my graph

Name of the node : Test

{
  "A": "1",
  "B": "2",
  "C": "3",
  "D": "4",
  "E": "5",
  "F": "6",
}

My application requires the graph DB to return A, B and C as key-value pairs as-is from the node, something like

A | 1
B | 2
C | 3

I know how to return all the key-value pairs in a specific node using

MATCH (n:Test)
UNWIND keys(n) AS Parameter
RETURN Parameter,n[Parameter] as Value

I am stuck in getting only specific key-value pairs. Any help would be much appreciated!

Hi Siddharth,

Wouldn't this work?

MATCH (n:Test)
return t.A, t.B, t.C

Or are you trying to dynamically find properties in some way?

This would return only the value of the property. I would also want the name of the property returned in additional to it's value.

Hi Siddharth

MATCH (n:Test)
UNWIND ['A','B','C'] AS Parameter
RETURN Parameter,n[Parameter] as Value

Hope this helps you.

1 Like

@siddharth.a

Welcome to the community !!

use parameter query. If your using Neo4j 4.0
try

:param a =>'A';

MATCH (n:Test{name:$a)
UNWIND keys(n) AS Parameter
RETURN Parameter,n[Parameter] as Value