Question

$queryString = "MATCH (n.Keywords) WHERE n.kw =~".$temp." RETURN n";
$query = new Everyman\Neo4j\Cypher\Query($client, $queryString);
$relativePosts = $query->getResultSet();

We are trying to accomplish a query that searches all of our Keywords that have a property kw that holds the words (Halo,Mustang...), it matches those values against a string variable that we already have set. Our example string variable is "Halo looks awesome".

In the end we are attempting to compare Mustang,Halo,Mario.. to "Halo looks awesome" and return Halo as it matches. Is it possible to use regular expressions with the node property values to compare to a string? Thanks!

Was it helpful?

Solution

Please use parameters and not string concatenation!

MATCH (n.Keywords) WHERE n.kw =~ {regexp} RETURN n

$params = array("regexp" => $temp)

You can store regexp-strings in node properties and check them against string-values, and the other way round, sure.

It's not clear what kind of regexp you are looking for though.

In general if you look for several words, something like this (Halo|Mustang) would be used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top