Ahoy, I'll answer inline too.

22.09.2011 10:51, Andres Taylor wrote:
> HI there,
>
> Answers inline,
>
> On Wed, Sep 21, 2011 at 8:16 PM, st.pa<st...@web.de>  wrote:
>
>> Hi,
>> I've got a Cypher query with some 10k possible source nodes and some 10k
>> intended target nodes out of some 1M possible target nodes which looks
>> something like the following:
>>
>> START source = (indexSourceNodes,"*"),
>>        target = (indexTargetNodes,"propertyTwo:*.txt")
>> MATCH (source)-[:needsThisRelationshipType]->(target)
>> WHERE (target.needsThisProperty)
>> RETURN source,target
>>
>> Now, how can I convince this query to speed up using a
>> relationship-index which I already constructed containing all the
>> neccessary relationships?
>
>
> This is something that we've planned to add to Cypher from day one, but
> still haven't put in. And it's because no-one ever asked for it. I'll add it
> in now, that we actually have users wanting it. Thanks for speaking up! I'm
> sorry you'll have to wait for it...

no problem. using the relationshipIndex.query() and hits iteration and 
then checking existance of that extra needed property is probably more 
efficient anyway.

>
>
>> How can I use regular expressions for an
>> index-subquery like this "propertyTwo:http(s)://.*\.txt" and how and
>> what needs to be escaped inside that subquery.
>>
>
> The way to do regular expressions is with the ~= operator. More info here:
> http://docs.neo4j.org/chunked/snapshot/query-where.html#where-regular-expressions
>
> Does that help?

yes, that helps for the WHERE clause.

<Example1>
START source = (indexSourceNodes,"propertyOne:%REGEX%"),
       target = ...
MATCH (source)-[relation]->(target)
RETURN relation
</Example1>

--> I can put my regex-query in the WHERE clause so that it filters the 
results of an index lookup.

<Example2>
START source = (indexSourceNodes,"propertyOne:*"),
       target = ...
MATCH (source)-[relation]->(target)
WHERE source.propertyOne =~ /%REGEX%/
RETURN relation
</Example2>

but what about regexes in the START clause where lookup of some 
nodeIndex with *-wildcard already takes place. this is obviously not 
pure regex, and I did not find documentation on what other wildcards are 
allowed or how to search for literal "*" - so what needs to be escaped 
there? \*, **, "*", \"*\", \\*, _, ?

other related question would be, how sophisticated is regex-support in 
the WHERE clause, like can I use backreferences as in
regexMatchRepeatedFolder="(/.+?)(/.+?)*?\1" ... well I could find that 
bit out on my own.


>
> Andrés
> _______________________________________________

St.P.

_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to