neo4j - Orderby desc multiple properties in Neo4jClient -
suppose have 4 photos , want return list sorted first on rating desc, second on ratingscount desc. below cypher query gives me correct result:
match (n:`photo`) n.ratingscount > 0 return n.rating, n.ratingscount order n.rating desc, n.ratingscount desc limit 20
id 1-rating 9-ratingscount 1
id 3-rating 7-ratingscount 2
id 2-rating 7-ratingscount 1
id 4-rating 2-ratingscount 1
unfortunately cannot translate neo4jclient. below query gives me photolist ordered rating ascending , ratingscount descending:
var query = await graphclient.cypher .match("(photo:photo)") .where((photoentity photo) => photo.ratingscount > 0); .returndistinct((photo) => new { photo = photo.as<photoentity>() }) .orderbydescending("photo.rating", "photo.ratingscount") .limit(20) .resultsasync;
id 4-rating 2-ratingscount 1
id 3-rating 7-ratingscount 2
id 2-rating 7-ratingscount 1
id 1-rating 9-ratingscount 1
if change order of rating , ratingscount photos in stranger order :) clue of doing wrong here?
var query = await graphclient.cypher .match("(photo:photo)") .where((photoentity photo) => photo.ratingscount > 0); .returndistinct((photo) => new { photo = photo.as<photoentity>() }) .orderbydescending("photo.ratingscount", "photo.rating") .limit(20) .resultsasync;
id 1-rating 9-ratingscount 1
id 2-rating 7-ratingscount 1
id 4-rating 2-ratingscount 1
id 3-rating 7-ratingscount 2
i took @ neo4jclient's source , orderbydescending()
string.join()s
arguments commas , adds 'desc' @ end. in other words: sorts asc on every property except last. agree counter intuitive tend avoid it.
you can use orderby()
instead:
orderby("photo.ratingscount desc, photo.rating desc")
Comments
Post a Comment