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