Thursday, 15 April 2010

neo4j - filtering a filtered a Cypher query result -



neo4j - filtering a filtered a Cypher query result -

hi here's current query i'd 're-filter':

start film = node(*) match user-[:like]->category-[:similar*0..3]-()<-[:tagged]->movie user.name = "current_user" distinct movie, user, category homecoming user.name, category.name, id(movie), movie.name order movie.name;

http://console.neo4j.org/r/u19iim

here's how looks after current query:

+--------------+----------------+-----------+-------------------------+ | user.name | category.name | id(movie) | movie.name | +--------------+----------------+-----------+-------------------------+ | current_user | c | 14 | movie_c_and_d_and_e | | current_user | d | 14 | movie_c_and_d_and_e | | current_user | e | 14 | movie_c_and_d_and_e | | current_user | | 9 | movie_of_a_and_b_and_b1 | | current_user | b | 9 | movie_of_a_and_b_and_b1 | | current_user | b | 10 | movie_of_b2_first | | current_user | b | 11 | movie_of_b2_second | | current_user | c | 12 | movie_of_c | | current_user | d | 13 | movie_of_d_and_e | | current_user | e | 13 | movie_of_d_and_e | +--------------+----------------+-----------+-------------------------+

i'd group count(sugg) category_count extract this:

+--------------+----------------+-----------+-------------------------+ | user.name | category_count | id(movie) | movie.name | +--------------+----------------+-----------+-------------------------+ | current_user | 3 | 14 | movie_c_and_d_and_e | | current_user | 2 | 9 | movie_of_a_and_b_and_b1 | | current_user | 2 | 13 | movie_of_d_and_e | | current_user | 1 | 10 | movie_of_b2_first | | current_user | 1 | 11 | movie_of_b2_second | | current_user | 1 | 12 | movie_of_c | +--------------+----------------+-----------+-------------------------+

how can accomplish this?

similar questions: - how have 2 aggregation in cypher query in neo4j?

update here's working result (with demo: http://tinyurl.com/cywlycc):

start film = node(*) match user-[:like]->category-[:similar*0..3]-()<-[:tagged]->movie user.name = "current_user" distinct movie, category count(movie) category_count, movie, collect(category.name) categorized homecoming category_count, id(movie), movie.name, categorized order category_count desc;

start film = node(*) match user-[:like]->category-[:similar*0..3]-()<-[:tagged]->movie user.name = "current_user" distinct movie, user, category homecoming user.name, count(category.name) category_count, id(movie), movie.name order category_count desc, movie.name asc

http://console.neo4j.org/r/69rfkn

neo4j cypher

No comments:

Post a Comment