How can I return all properties for a node using Cypher?

前端 未结 6 1872
梦谈多话
梦谈多话 2020-12-15 17:23

I understand it is possible to use the wildcard (*) symbol to return all references in a Cypher query, such as:

MATCH p:Product WHERE p.price=\'1950\' RETURN         


        
相关标签:
6条回答
  • 2020-12-15 17:50

    In the latest version of cypher properties(n) will return all the keys and properties of a node. Seems to only work for a single node though.

    I hope this helps people.

    0 讨论(0)
  • 2020-12-15 17:50

    Just to expand on getting the keys:

    MATCH (p:product) WITH DISTINCT keys(p) AS keys
    UNWIND keys AS keyslisting WITH DISTINCT keyslisting AS allfields
    RETURN allfields;
    
    0 讨论(0)
  • 2020-12-15 17:51

    I'm new to cypher, but it seems that this returns all the keys for a particular type of node:

    MATCH (p:product) RETURN keys(p)
    

    Works in Neo4J 3.0.

    0 讨论(0)
  • 2020-12-15 17:56

    You can't do this in Cypher yet. I think it would be a nice feature though, if you want to request it.

    Edit (thanks for comment pointing it out): You can now do this as of 2.2:

    MATCH (p:Product) WHERE p.price='1950' RETURN keys(p);
    
    0 讨论(0)
  • 2020-12-15 18:01

    You can return n in your cypher query, it will return all the keys and properties of a node. eg.: MATCH (n:People) n
    This will return
    n:
    { "Date_of_Birth": "1981-04-23 00:00:00", "Employee_Last_Name": "Aaaa", "Employee_First_Name": "Baaa", "Age": 36, "Employee_Status": "Active" }

    0 讨论(0)
  • 2020-12-15 18:11

    You can use the 'as' clause and identify each property and what you want the column to be named. You will have to identify each property you want returned individually though.

    ex:

    MATCH p.product where WHERE p.price='1950' RETURN p.price as price, p.title as title, p.whatever, as anythingYouWant
    
    0 讨论(0)
提交回复
热议问题