Database Reference
In-Depth Information
Forstringproperties,inadditiontothestandardequals( = )comparison,youcanuseregular
expressions to filter out specific values. To find all friends who have an email address con-
taining “gmail.com”, for example, you could run the following query:
As you can see, the regular expression comparison operator in Cypher is =~ (equals tilde).
The regular expression is placed between two forward slashes ( / ). The expression itself
follows the standard Java regular expression syntax (see http://docs.oracle.com/javase/tu-
torial/essential/regex/ for more information).
But what would happen if you don't have an email address stored for all users or nodes?
As we discussed earlier, Neo4j allows for a semi-structured, schemaless data structure, so
no two nodes have to have the same set of properties. The sample data set distributed with
this topic has an email property for some of the user nodes but not all. Let's see how to
use Cypher to query for properties that aren't shared by all nodes.
Tofilternodesthathaveagivenproperty,regardlessofthepropertyvalue(forexample,all
friends who have a Twitter account), you need to use the Cypher function has :
As you can see, filtering results in Cypher isn't difficult, and it looks very similar to the
SQL where clause.
In the next section we'll take a look at the different types of results you can return from a
Cypher query.
6.2.4. Getting the results
The results of a Cypher query are returned in the return clause. So far you've used it to
return nodes you're interested in, but the return clause isn't limited to nodes only—you
Search WWH ::




Custom Search