As I said such a generic one will probably not be fast.

the union all is imho fastest

> Am 15.03.2015 um 17:01 schrieb Martin Troup <troup...@gmail.com>:
> 
> Great! So I execute:
> 
> MATCH path=some_graph_pattern
> AND ALL(n in nodes(path) WHERE id(n) IN {node_ids}) 
> AND ALL(r in rels(path) WHERE id(r) IN {rel_ids}) 
> RETURN path
> 
> and now I would like to know if the execution of this query is going to be 
> fast. (I need it to be as fast as possible).
> 
> In your first reply you said that quite similar query:
> 
> MATCH path = (a)-[]-(b)-[]-(c)
> WHERE ANY(r in rels(path) WHERE id(r) = 5)
> RETURN path
> 
> is going to be super slow comparing to: 
> 
> match path = (a)-[r]-(b)-[]-(c)
> where id(r) = 5
> return path
> union
> match path = (a)-[]-(b)-[r]-(c)
> where id(r) = 5
> return path
> 
> so is the query with AND ALL clause going to be fast?
> 
> Thanks again!
> 
> Dne čtvrtek 12. března 2015 10:45:51 UTC+1 Michael Hunger napsal(a):
> something like this
> 
> MATCH path=(n)-[*..5]-() 
> where id(n) = {node_ids}[0]
> AND ALL(n in nodes(path) WHERE id(n) IN {node_ids}) 
> AND ALL(r in rels(path) WHERE id(r) IN {rel_ids}) 
> return path
> 
> 
>> Am 10.03.2015 um 22:40 schrieb Martin Troup <trou...@ <>gmail.com 
>> <http://gmail.com/>>:
>> 
>> Thanks for your reply!
>> 
>> So let me change the problem a little bit. Let say I know all of the nodes 
>> and relationships (its IDs) where I want to search for a pattern (for 
>> example triangle). Can I define a cypher query with MATCH clause, that will 
>> find a triangle (or any graph pattern) between those defined relationships 
>> and nodes?
>> 
>> The problem in general would be to execute a cypher query on a subgraph that 
>> I define (by naming all of nodes and relationships IDs).
>> 
>> So I am looking for something like:
>> 
>> 
>> 
>> MATCH any_graph_pattern
>> 
>> IN (node_id_4, node_id_3, … , relationship_id_1, …)
>> 
>> 
>> 
>> If there is such a way to express this with Cypher, is the execution of the 
>> query going to be fast enough? If the subgraph where I am looking for the 
>> graph pattern is going to be small enough.
>> 
>> 
>> Thanks again for your time!
>> Martin
>> 
>> Dne úterý 10. března 2015 11:31:10 UTC+1 Michael Hunger napsal(a):
>> There is no universal way
>> 
>> this is a quite generic approach but it will be super slow
>> 
>> MATCH path = (a)-[]-(b)-[]-(c)
>> WHERE ANY(r in rels(path) WHERE id(r) = 5)
>> RETURN path
>> 
>> it is better if you can do:
>> 
>> match path = (a)-[r]-(b)-[]-(c)
>> where id(r) = 5
>> return path
>> union
>> match path = (a)-[]-(b)-[r]-(c)
>> where id(r) = 5
>> return path
>> 
>> Michael
>> 
>>> Am 10.03.2015 um 11:24 schrieb Martin Troup <trou...@ <>gmail.com 
>>> <http://gmail.com/>>:
>>> 
>>> Hello everyone,
>>> 
>>> 
>>> 
>>> lets say I have a graph pattern (for example (a)-[]-(b)-[]-(c), but it can 
>>> be any graph pattern). I want to find this graph pattern with Cypher query. 
>>> I know partial information about the exact pattern I am looking for, for 
>>> example some of node IDs, or relationship IDs.
>>> 
>>> Here I will show an example. I am looking for a pattern (a)-[]-(b)-[]-(c) 
>>> and I know there is a relationship with ID 5 in it, but I don’t know its 
>>> position. So it can be the one between nodes a and b or between b and c.
>>> 
>>> I am wondering if there is an universal way to express this with Cypher 
>>> query, something like 
>>> 
>>> 
>>> 
>>> MATCH any_graph_pattern
>>> 
>>> WHERE relationship_id(5)
>>> 
>>> 
>>> 
>>> where I can say which exact relationships or nodes are part of the graph 
>>> pattern I am looking for even though I don’t know their position within it.
>>> 
>>> 
>>> 
>>> Thanks a lot for a reply!
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Neo4j" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to neo4j+un...@ <>googlegroups.com <http://googlegroups.com/>.
>>> For more options, visit https://groups.google.com/d/optout 
>>> <https://groups.google.com/d/optout>.
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to neo4j+un...@googlegroups.com <>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com 
> <mailto:neo4j+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to