Hi Michael,
Thank you very much! Your answers are very helpful to me. Although I have read the manual enclosed in the neo4j package I downloaded I did not know that we can use * wildcard for any ids or names. Besides the manual what other resources can I find to understand more about Cypher? Appreciated your help. A. ________________________________ From: Michael Hunger <[email protected]> To: Neo4j user discussions <[email protected]> Sent: Wednesday, November 2, 2011 5:31 PM Subject: Re: [Neo4j] Cypher questions Both your questions would be answered with indexing: for the 1) you would add the user nodes them to a "User" index and then use start user=node:User("id:*") ... For 2) you would index the relationships-similarly (for the interesting types). e.g. create an index for only the rel-type you're interested in: index().forRelationships("go_to_school").add(rel, "key","value") key and value are arbitrary things, but you might leverage them with sensible data in your domain model. start r = relationship:go_to_school("field:*") match (x)-[r]->(n) where n.name = "Notre Dame" return x !! usually you would probably rather index the schools, and look them up directly start school = node:schools("name",{school_name}) match pupil-[:go_to_school]->school return pupil (You could use auto-indexing for both if that is useful for you, the index-names would then be node_auto_index and relationship_auto_index, see : http://docs.neo4j.org/chunked/snapshot/auto-indexing.htmlhttp://docs.neo4j.org/chunked/snapshot/rest-api-auto-indexes.html ) Am 03.11.2011 um 00:35 schrieb andrew ton: > > > Hello, > > I have some questions regarding Cypher. > > 1. I have an ontology that defines classes and individuals. I store this > ontology into Neo4J REST db. Is there any ways to find all individuals that > have some given class? > In SPARQL, it can be done like "...WHERE { ?u a :User.}..." to find all > instances that have a type of User. > > 2. Similar to the question#1, if I understand correctly in Cypher I always > have to start with a known node either by its ID or name. If so how to find > any nodes that have some given relationship? > For example, I want to find any nodes that have the the relationship type > "go_to_school". > > (x)-[:go_to_school]->(n) where (n.name= "NotreDame") return x > > Thank you, > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

