Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-31-2021 10:20 PM
I tried this query but failed with three conditions like this:
match (s:Stem)-[:STEM_OF]->(w:Word) where not w.vocab ends with 'XX' or not w.vocab ends with 'YY' or not w.vocab ends with 'ZZ'
return w.vocab, s.vocab limit 100
But it works with where not(w.vocab ends with 'XX' or w.vocab ends with 'YY' or w.vocab ends with 'ZZ')
Solved! Go to Solution.
02-01-2021 08:38 AM
Hi Gigauser,
I think what goes wrong here is that the two statements
NOT Statement A OR NOT Statement B OR NOT Statement C
and
NOT (Statement A OR Statement B OR Statement C)
are NOT (!) the same.
It is
NOT Statement A OR NOT Statement B OR NOT Statement C = NOT (Statement A AND Statement B AND Statement C)
on the one hand and on the other hand
NOT Statement A AND NOT Statement B AND NOT Statement C = NOT (Statement A OR Statement B OR Statement C).
But these two lines are not the same!
What probably happens is that you first query just gives you all words and not just the ones that you were looking for, right? This is because all words do not end in all (!) three of your endings. Your second query gives you what you want because there you look for all words that do not end in any (!) of the endings.
For further reference: this is called the De Morgan's laws ( De Morgan's laws - Wikipedia)
Regards,
Elena
02-01-2021 04:35 AM
I tried this query but failed with three conditions
how so?
you got wrong/unexpected results?
or you got an error?
Also what version of Neo4j is in use here?
02-01-2021 08:38 AM
Hi Gigauser,
I think what goes wrong here is that the two statements
NOT Statement A OR NOT Statement B OR NOT Statement C
and
NOT (Statement A OR Statement B OR Statement C)
are NOT (!) the same.
It is
NOT Statement A OR NOT Statement B OR NOT Statement C = NOT (Statement A AND Statement B AND Statement C)
on the one hand and on the other hand
NOT Statement A AND NOT Statement B AND NOT Statement C = NOT (Statement A OR Statement B OR Statement C).
But these two lines are not the same!
What probably happens is that you first query just gives you all words and not just the ones that you were looking for, right? This is because all words do not end in all (!) three of your endings. Your second query gives you what you want because there you look for all words that do not end in any (!) of the endings.
For further reference: this is called the De Morgan's laws ( De Morgan's laws - Wikipedia)
Regards,
Elena
02-03-2021 11:00 PM
Thank you for the tips!
God bless you and dana!
All the sessions of the conference are now available online