0

I'm attempting to find all values that match any item within a list of values within cypher. Similar to a SQL query with in and not in. I also want to find all values that are not in the list in a different query. The idea is I want to assign a property to each node that is binary and indicates whether the name of the node is within the predefined list.

I've tried the following code blocks:

MATCH (temp:APP) - [] -> (temp2:EMAIL_DOMAIN)
WHERE NOT temp2.Name IN ['GMAIL.COM', 'YAHOO.COM', 'OUTLOOK.COM', 'ICLOUD.COM', 'LIVE.COM']
RETURN temp

This block returns nothing, but should return a rather large amount of data.

MATCH (temp:APP) - [] -> (temp2:EMAIL_DOMAIN)
WHERE temp2.Name NOT IN ['GMAIL.COM', 'YAHOO.COM', 'OUTLOOK.COM', 'ICLOUD.COM', 'LIVE.COM']
RETURN temp

This code block returns an error in relation to the NOT's position. Does anyone know the correct syntax for this statement? I've looked around online and in the neo4j documentation, but there are a lot of conflicting ideas with version changes. Thanks in advance!

  • please do data analysis on EMAIL_DOMAIN.Name; Run this and see the different email domains in your database. MATCH (t: EMAIL_DOMAIN) RETURN DISTINCT t.Name – jose_bacoy Jan 27 '23 at 20:59
  • If all your data says ['GMAIL.COM', 'YAHOO.COM', 'OUTLOOK.COM', 'ICLOUD.COM', 'LIVE.COM'], then your query will not return any rows. – jose_bacoy Jan 27 '23 at 21:01

1 Answers1

1

Neo4j is case sensitive so you need to check the data to ensure that the EMAIL_DOMAIN.Name is all upper case. If Name is mixed case, you can convert the name using toUpper(). If Name is all lower case, then you need to convert the values in your query.

MATCH (temp:APP) - [] -> (temp2:EMAIL_DOMAIN)
WHERE NOT toUpper(temp2.Name) IN ['GMAIL.COM', 'YAHOO.COM', 'OUTLOOK.COM', 'ICLOUD.COM', 'LIVE.COM']
RETURN temp
jose_bacoy
  • 12,227
  • 1
  • 20
  • 38
  • Case shouldn't be an issue as everything has already been converted to upper case in python, but from what I can tell everything else is looking fine. So I'm unsure where to go from here. – DScience97C Jan 27 '23 at 20:04
  • the syntax is WHERE NOT in . If you are not getting the result that you expect then please give us example data and we will help. Thanks. – jose_bacoy Jan 27 '23 at 20:09