2
votes

Say I've created a node in Neo4j:

CREATE (:Thing {a:'foo', b:'bar'})

I can write a query to get that node with all of its properties

MATCH (n:Thing {a:'foo'}) RETURN n

which returns

{
  "a": "foo",
  "b": "bar"
}

but is it possible to match a node and retrieve only a subset of its properties, so that for example, Neo4j would return a node with only

{
  "b": "bar"
}

(Not looking for just the property, like you would get via RETURN n.b)

1

1 Answers

4
votes

Yes, you can use map projections in Cypher, for eg :

MATCH (n:Thing {a:'foo'}) RETURN n{.a}

will return :

 {a:"foo"}

More info in the documentation