Friday, 15 January 2010

neo4j - Matching pattern with optional nodes -



neo4j - Matching pattern with optional nodes -

i have cypher query tries capture nodes in order:

a:genus-->b:family-->c:order-->d:class-->e:phylum

with labels genus, family, order, class, phylum , homecoming similar table below.

each of nodes a:e have other properties in reality, nodes may linked in next manner

a:genus --> b:no_rank --> c:family --> d:class --> e:no_rank --> f:phylum

how capture such construction pattern may miss label or have additional nodes in between single query.

currently cypher query looks this:

start basetaxa=node:ncbitaxid('taxid:2006379') match basetaxa-[:childof*0..]->(genus:`genus`)-[:childof*0..]->(family:`family`)-[:childof*0..]->(order:`order`)-[:childof*0..]->(class:`class`)-[:childof*0..]->(phylum:`phylum`) homecoming genus.taxid,family.taxid,order.taxid,class.taxid,phylum.taxid;

which returns this

+-----------------------------------------------------------------------+ | genus.taxid | family.taxid | order.taxid | class.taxid | phylum.taxid | +-----------------------------------------------------------------------+ | 914 | 206379 | 32003 | 28216 | 1224 | +-----------------------------------------------------------------------+ 1 row

neo4j cypher

No comments:

Post a Comment