You should use Labels for a and c like :Day and an index on :Day(date)

and you only have to match listings on the node in the middle


> MATCH path = (a:Date)-[:NEXT_DAY*]->(c:Date)
> WHERE a.date="2015-01-20" AND c.date="2015-01-24"
> UNWIND nodes(p) as d
> MATCH (listing:Listing)-[:AVAILABLE]->(d:Date) RETURN d, collect(listing) as 
> listings



> Am 05.06.2015 um 12:29 schrieb Benjamin Pipat <[email protected]>:
> 
> Hi,
> 
> I'm trying to match listing availabilities in my graph (Airbnb-like). 
> 
> * The graph has 1 node per date, and consecutive days are linked by a 
> NEXT_DAY edge.
> * Listings are linked to day nodes by an AVAILABLE edge (if they are 
> available)
> 
> I'm trying to write a query which return all listings which are available 
> from start_date to end_date.
> 
> I know the following syntax is wrong but I may help giving the general idea
> 
> MATCH period=(a)-[:NEXT_DAY*]->(c)
> WHERE a.date="2015-01-20" AND c.date="2015-01-24"
> 
> MATCH (listing:Listing)-[:AVAILABLE]->(d:Date)
> FOREACH (d IN nodes(period))
> 
> RETURN listing
> 
> Bonus question: How could I proceed if I wanted to score listings 
> proportionally to their availability match with the query (e.g. 100% if the 
> listing is available during the whole period, 50% if it is only available 
> half of the period) ?
> 
> Thanks in advance :)
> 
> Benjamin
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to