Why this query doesn't work in bolt session?


(Gigauser) #1
result, err = session.Run("with $inputword as list match (p:Person) where p.name in list return p.age as ages",
	map[string]interface{}{"inputword": "['name1', 'name2']"})

The query work well in web browser but not in Go program.


(Matthew Browning) #2

Not 100% sure, but I believe you need to do something like this:

cypher := `with $inputword as list match (p:Person) where p.name in list return p.age as ages`
result, err = session.Run(cypher, map[string]interface{}{
	"inputword": []string{"name1", "name2"},
})

(Ali Ince) #3

@gigauser, In the code you've pasted, you're passing inputword as a string - not a list; that wouldn't work as intended.

You can however, send them as a slice in go so that they're encoded as lists as intended.

session.Run("with $inputword as list match (p:Person) where p.name in list return p.age as ages", map[string]interface{}{"inputword": []string{ "name1", "name2" }})