6

I cannot update the node using SET for multiple properties in Neo4j, is there any way to handle this?

start n=node:wordindex(word='repine') set     n.wordType = 'rare'         return n

If I want to add n.link = "..." how is that done?

user2580874
  • 129
  • 1
  • 6

3 Answers3

13

Here is the newest doc: http://neo4j.com/docs/developer-manual/current/cypher/clauses/set/

 MATCH (n { name: 'Peter' })
 SET n += { hungry: TRUE , position: 'Entrepreneur' }

There are other ways also, so check the docs.

Also check this out if you are doing this from node.js: JSON.Stringify without quotes on properties?

You can use util.inspect() to get an object in like this:

 const util = require('util')

 const params = {
   hungry: TRUE ,
   position: 'Entrepreneur'
 }

 const query = `
   MATCH (n { name: 'Peter' })
   SET n += ${util.inspect(params)}
   RETURN n
 `
agm1984
  • 15,500
  • 6
  • 89
  • 113
9
start n=node:wordindex(word='repine')
set n.wordType = 'rare', n.link='link'
return n

should do it

Luanne
  • 19,145
  • 1
  • 39
  • 51
1

I have an example which i have tried and worked!

Below is the cypher query created the node:

CREATE (n:myAsset {name: 'Test CBP2', Description: 'my test Description', GUID: 'ID000002', Subtype: 'cat-a-cb', Notes: 'my_Notes'  })

I have updated multiple properties by using SET:

MATCH (n:myAsset {GUID: 'ID000002'}) SET n.Description='Updated description',n.Subtype='cat-b-cb', n.Notes='New Notes added' RETURN n
Tono Kuriakose
  • 718
  • 6
  • 19