I have a graph with two vertices, and each contain a property named interests
, which is an array of strings. I wanted to compare how many strings both arrays have in common and also if the array contains a certain string.
I have tried the following query, but it throws an error:
SELECT * FROM cypher('QuirkyMatch', $$
MATCH (v:Person), (user:Person)
WHERE user.name = 'Sarah' AND v.age > (user.age + 1) AND v.interests CONTAINS 'Art'
RETURN v
$$) as (potential_match agtype);
ERROR: agtype string values expected
Here is how I created them:
SELECT * FROM cypher('QuirkyMatch', $$
CREATE (:Person {
name: 'Alex',
age: 27,
occupation: 'Graphic Designer',
interests: ['Art', 'Photography', 'Traveling', 'Indies Music'],
weird_fact: 'I can hold up to 400 straws in my mouth. LOL.'
}),
(:Person {
name: 'Sarah',
age: 25,
occupation: 'Software Engineer',
interests: ['Hiking', 'Board Games', 'Sci-Fi Movies', 'Dungeons & Dragons', 'Painting', 'Art'],
weird_fact: 'I collect hot sauces and I have over 50 different ones :)'
})
$$) as (v agtype);
2
Answers
You can use IN operator for array. Here is how you can achieve the desired output.
Try using the
IN
keyword instead.This answer is 100% my own work.