{"action":"created","issue":{"url":"https://api.github.com/repos/neo4jrb/neo4j/issues/866","labels_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/866/comments","events_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/866/events","html_url":"https://github.com/neo4jrb/neo4j/issues/866","id":94970551,"number":866,"title":"Returning Pair results in Core-Query","user":{"login":"YanZhenLin","id":6042757,"avatar_url":"https://avatars.githubusercontent.com/u/6042757?v=3","gravatar_id":"","url":"https://api.github.com/users/YanZhenLin","html_url":"https://github.com/YanZhenLin","followers_url":"https://api.github.com/users/YanZhenLin/followers","following_url":"https://api.github.com/users/YanZhenLin/following{/other_user}","gists_url":"https://api.github.com/users/YanZhenLin/gists{/gist_id}","starred_url":"https://api.github.com/users/YanZhenLin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YanZhenLin/subscriptions","organizations_url":"https://api.github.com/users/YanZhenLin/orgs","repos_url":"https://api.github.com/users/YanZhenLin/repos","events_url":"https://api.github.com/users/YanZhenLin/events{/privacy}","received_events_url":"https://api.github.com/users/YanZhenLin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-14T15:19:11Z","updated_at":"2015-07-14T18:04:30Z","closed_at":null,"body":"Hi Chris, I'm having trouble returning pair results using the core-query return function. The cypher query that I am trying to replicate in core-query is something of this form:\r\n\r\n```cyphecr\r\n  MATCH (users:`User`), (user2:`User`), users-[:lives_in]->(country:Country)<-[:lives_in]-(user2:User), (user2)-[:has_been_to]-(visitedList:Country), (user2:`User`)\r\n  WHERE ( visitedList.name IN ['United States', 'Canada'])\r\n  RETURN user2, count(user2) AS strength\r\n  ORDER BY strength DESC\r\n```\r\n\r\nusing some template strings, I have worked out my core query to be the following:\r\n\r\n```ruby\r\nmatch_exp = 'users-[:lives_in]->(country:Country)<-[:lives_in]-(user2:User), (user2)-[:has_been_to]-(visitedList:Country)'\r\n\r\nwhere_exp = 'visitedList.name IN ['United States', 'Canada']'\r\n\r\nreturn_exp = 'user2, count(*) AS strength'\r\n\r\n@matches = User.query_as(:users).match(user2: User).match(\"#{match_exp}\").where(\"#{where_exp}\").return(\"#{return_exp}\").proxy_as(User, :user2).order(strength: :desc)\r\n```\r\n\r\nwhich I turn back into a proxy query for later use on ActiveNode. The problem is that when I run the script, it generates the following query:\r\n\r\n```cypher\r\n  MATCH (users:`User`), (user2:`User`), users-[:lives_in]->(country:Country)<-[:lives_in]-(user2:User), (user2)-[:has_been_to]-(visitedList:Country), (user2:`User`)\r\n  WHERE (visitedList.name IN ['United States','Canada']')\r\n  RETURN count(user2) AS user2\r\n```\r\n\r\nwhich returns a non pair-wise result of all users living in United States or Canada. I know I am misusing the return function in such a way that it converts `RETURN user2, count(*) AS strength`  to `RETURN count(user2) AS user2`. What is the proper way to return a paired result in this case?"},"comment":{"url":"https://api.github.com/repos/neo4jrb/neo4j/issues/comments/121325274","html_url":"https://github.com/neo4jrb/neo4j/issues/866#issuecomment-121325274","issue_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/866","id":121325274,"user":{"login":"YanZhenLin","id":6042757,"avatar_url":"https://avatars.githubusercontent.com/u/6042757?v=3","gravatar_id":"","url":"https://api.github.com/users/YanZhenLin","html_url":"https://github.com/YanZhenLin","followers_url":"https://api.github.com/users/YanZhenLin/followers","following_url":"https://api.github.com/users/YanZhenLin/following{/other_user}","gists_url":"https://api.github.com/users/YanZhenLin/gists{/gist_id}","starred_url":"https://api.github.com/users/YanZhenLin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YanZhenLin/subscriptions","organizations_url":"https://api.github.com/users/YanZhenLin/orgs","repos_url":"https://api.github.com/users/YanZhenLin/repos","events_url":"https://api.github.com/users/YanZhenLin/events{/privacy}","received_events_url":"https://api.github.com/users/YanZhenLin/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T18:04:30Z","updated_at":"2015-07-14T18:04:30Z","body":"@matches = User.query_as(:users).match(user2:\nUser).match(\"#{match_exp}\").where(\"#{where_exp}\").order(strength:\n:desc).return(:user2, strength: 'count(user2)') returns a enumerable of\ncouples at the moment, I am trying to map the enumerable of pairs into just\nan enumerable of only users.\n\nOn Tue, Jul 14, 2015 at 12:51 PM, Brian Underwood <notifications@github.com>\nwrote:\n\n> Gotcha ;) Just a clarification on the terminology, pluck returns an Array\n> which happens to be Enumerable, and return returns a QueryProxy which\n> also happens to be enumerable (and a lazy-loading object, meaning it\n> doesn't query until the enumeration happens).\n>\n> Did the above solve the issue?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/neo4jrb/neo4j/issues/866#issuecomment-121306199>.\n>\n"}}