Hello neo4j,
Hope you guys having a nice day today.
By the way, I made some queries for showing the place is associated with some city.
So, I want to limit the result place of each city. for example,
if location A is related with 10 City and location B is related with 10 cities, I just want to reduce the number of each result as 6. ( location A is related with 6 places, and location B is related with 6 places)
For my business logic, I use where any() clause for showing variety Possibility of results.
here is my code.
MATCH (place)<-[:IS_Location]-(location:Location)
WHERE any (
filters IN ['ALL', 'B', 'C', 'D', 'E']
WHERE (place)<-[:IS_Location]-(location{name : filters})
with distinct location // I add this statement
limit 10 // and this statement
)
I add two statements, but it doesn't work.
I really need some help and also any comments would be appriciated.
MATCH (place)
CALL {
WITH place
MATCH (place)<-[:IS_Location]-(location:Location)
WHERE any(filter IN ['ALL', 'B', 'C', 'D', 'E'] WHERE location.name = filter)
RETURN DISTINCT location, place
LIMIT 10
}
RETURN location, place
Sure, I'm sorry, since you didn't specify the neo4j version, I thought you were on 4.0
MATCH (place)
WITH id(place) AS idp
CALL apoc.cypher.run('
MATCH (place)<-[:IS_Location]-(location:Location)
WHERE id(place) = $idp
AND any(filter IN $filters WHERE location.name = filter)
RETURN DISTINCT location, place
LIMIT 10
', {idp:idp, filters:['ALL', 'B', 'C', 'D', 'E']}) YIELD value
RETURN value.location AS location, value.place AS place