Mark, I have emailed you the query and profile for both cases.

On Tuesday, January 21, 2014 10:55:03 AM UTC-6, Javad Karabi wrote:
>
> Mark, I would be happy to. Give me a moment and I will post them.
>
> Michael, 
>    
>    - Kernel version
>    
>    neo4j-browser, version: 2.0.0
>    - 
>    
>
> On Tuesday, January 21, 2014 10:49:37 AM UTC-6, Michael Hunger wrote:
>>
>> Java, what version are you using?
>>
>> 2.0 final?
>>
>> Michael
>>
>> Am 21.01.2014 um 17:29 schrieb Javad Karabi <karab...@gmail.com>:
>>
>> from what I can tell, if there where clause is ">" or "<" (as it is in 
>> the actual query which i am using, not in this example query...) then the 
>> WHERE predicate _is in fact_ a filter, applied _after_ the match. It looks 
>> to me that "TraversalMatcher()" does not apply predicates which involve > 
>> or <, but instead delegates this to "Filter()" after the fact, which does 
>> not correlate with what is stated on the documentation.
>>
>> On Tuesday, January 21, 2014 10:25:41 AM UTC-6, Javad Karabi wrote:
>>>
>>> (c:Customer)-[:ordered]->(p:Product)-[:category]->(:Category)
>>>
>>> Now, say that there are 2:
>>> c-[:ordered]->(:Product { name: "pants", quantity: 10})
>>> c-[:ordered]->(:Product { name: "shirt",   quantity: 5})
>>>
>>> Now, say that if I only want to cross the category relationship if the 
>>> p.quantity > 6
>>>
>>> In the most basic way, I would do:
>>>
>>> (c:Customer)-[:ordered]->(p:Product)-[:category]->(cat:Category)
>>> WHERE p.quantity > 6
>>>
>>> However, I figured that maybe neo4j would (non-optimally) traverse the 
>>> entire path _then_ filter where on top of the path.
>>>
>>> So what I did was:
>>>
>>> MATCH (c:Customer)-[:ordered]->(p:Product)
>>> WHERE p.quantity > 6
>>> WITH p
>>> MATCH p-[:category]->(cat:Category)
>>>
>>> This, I figured, would then allow neo4j to cross out to all the product 
>>> nodes, as I would need them anyway in order to filter out the ones which 
>>> have a quantity of less than 6.
>>>
>>>
>>> Now... finally to my question.
>>> The following URL:
>>> http://docs.neo4j.org/chunked/stable/query-match.html
>>> states that:
>>> WHERE defines the MATCH patterns in more detail. The predicates are 
>>> part of the pattern description, not a filter applied after the matching is 
>>> done. 
>>>
>>> So, my question is, if the predicates (specifically p.quantity > 6) are 
>>> part of the pattern description, and _not_ applied _after_ matching 
>>> (therefore applied before or during), then cutting the query with the WITHs 
>>> would be a moot point
>>>
>>> So, I would think that 
>>>
>>> (c:Customer)-[:ordered]->(p:Product)-[:category]->(cat:Category)
>>> WHERE p.quantity > 6
>>> would be sufficient, , as neo4j _would not_ actually traverse to cat, 
>>> since it would apply the filter during the match process.
>>>
>>> However, in practice, I notice that using WITH is actually faster. Is 
>>> there any possible reason for this?
>>> It may be necessary for me to show my query exactly, I also have the 
>>> profile data for the query, which I am currently analyzing
>>>
>>
>> -- 
>> 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/groups/opt_out.
>>
>>
>>

-- 
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/groups/opt_out.

Reply via email to