cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Problem with "Intermediate Cypher Queries Course" Testing List Inclusion

Hi All.
I am learning "Intermediate Cypher Queries Course"
Testing List Inclusion | GraphAcademy (neo4j.com)

It Require me to:

Neo4j supports storing a single value or an array of values of the same type within a property.

In our data model, every :Movie node has a languages property which contains an array of strings. For example ['English', 'German', 'Italian'].

Finding German Language Movies

Write and execute a query to return people who both acted in and directed a movie released in the German language.

How many unique Person node names are returned? (There will be duplicates that you should not count)


BUt when I check in sandbox with the query:

match (m:Movie) 
where m.languages contains "German"
    return m
It return no Record. I am wondering why? Haiza.




1 ACCEPTED SOLUTION

“in” is used with lists to determine if a list contains an element. 

"German" in m.languages is asking if the list contained in the property m.languages has an element equal to “German”

“contains” is used with string values to determine is a string contains another string as a subset or is equal. 

m.languages CONTAINS "German" Is asking if the string stored in the property m.languages contains “German” as a substring or is equal to “German”

View solution in original post

3 REPLIES 3

The 'contains' clause you are using is for determining if a string value contains another string. What you are looking for is the 'in' clause for lists.

match (m:Movie) 
where "German" in m.languages
return m

 

Yeah, It OK Sir, But What is the deffirent in the clause Where
Where "German" in m.languages

and Where m.languages CONTAINS "German" 

“in” is used with lists to determine if a list contains an element. 

"German" in m.languages is asking if the list contained in the property m.languages has an element equal to “German”

“contains” is used with string values to determine is a string contains another string as a subset or is equal. 

m.languages CONTAINS "German" Is asking if the string stored in the property m.languages contains “German” as a substring or is equal to “German”

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online