For example, If a 'name' property's value is "iPhone 7" and my query term is "iPhone 8" I also want it to be matched.
match (n) WHERE n.name ~= $name ($name = 'iPhone 8')
If 'name' is 'iPhone 7', I want this returns true. Generally, if two strings largely matche, I want them to be matched:
"aabcde" matches "cdef": cde matches, but the 'contains' function won't work.
How to match at least these two examples in Cypher? Is this possible at all?
That specific example can use STARTS WITH. Also look at CONTAINS. Regular expressions will incur a performance hit.
From WHERE Clauses:
The STARTS WITH operator is used to perform case-sensitive matching on the start of strings.
MATCH (n)
WHERE n.name STARTS WITH 'Pet'
RETURN n.name, n.age
The name and age for the 'Peter' node are returned because his name starts with 'Pet'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With