Why this query doesn't work in bolt session?

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.

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"},
})

@Dongho, 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" }})
1 Like