Hi Simon, my mistake, I was not clear at all, the sort() function is not a built-in function, my proposal was to implement your own function called sort() in javascript and use it in the query
Luigi 2014-11-25 16:55 GMT+01:00 Simon L <si...@pumpup.co>: > Thanks for the reply. > > I cannot find any documentation on the `sort()` function. It did not seem > to work on my 2.0 version of the database. Also, does this function > properly support large datasets? Again, there could theoretically be 10,000 > comments. > > Version text: `OrientDB Server v2.0-SNAPSHOT is active. [OServer]` > > What I tried: > orientdb {db=pumpup}> select set($comments[0], $comments[1], $comments[2]) > from #22:411474 let $comments = sort(out('PostHasComment')) > > `Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: > Error on parsing command at position #0: No function with name 'sort', > available names are : > [date,encode,distance,document,distinct,dijkstra,traversedelement,sum,decode,bothv,uuid,out,mode,sysdate,avg,min,shortestpath,traversededge,ifnull,traversedvertex,stddev,outv,if,map,bothe,unionall,ine,set,oute,intersect,last,max,in,coalesce,count,format,label,list,both,inv,gremlin,eval,percentile,median,variance,difference,first]` > > > > On Tuesday, November 25, 2014 3:26:46 AM UTC-5, Luigi Dell'Aquila wrote: >> >> Hi Simon, >> >> you can do something like this >> >> select set($comments[0], $comments[1], $comments[2]) from SOME_POST_ID >> let $comments = sort(out('PostHasComment')) >> >> or >> >> but edges are not guaranteed to be sorted, so you have to write your own >> sort() function. >> >> If you are using M3 or earlier, function execution (like sort() ) can be >> quite slow, anyway this issue was just fixed yesterday, so you can rely on >> it. >> >> Hope it helps >> >> Luigi >> >> >> Il giorno domenica 23 novembre 2014 17:10:24 UTC+1, Simon L ha scritto: >>> >>> Here's our issue.. >>> >>> Suppose we have a social network with: >>> class Post >>> class Comments >>> class Likes >>> class OUser >>> >>> We want to the post object, comments and likes in one query. There could >>> be 1000 comments on a Post object, but we only want to fetch the post and 3 >>> most recent comments and likes attached to it. >>> >>> What's the fastest way to do this? >>> >>> My current thinking is that a fetchPlan would be fastest, like this: >>> *SELECT from SOME_POST_RID FETCHPLAN >>> 'out_PostHasComment.in.in_UserWroteComment.out:1 in_UserWrotePost.out:1 >>> in_UserLikesPost.out:1'* >>> BUT how can I limit the items of a fetchPlan in addition to the depth? >>> FetchPlan doesn't seem to limit the # of items you can retrieve (we'd also >>> need to sort by date). >>> >>> Alternatively, I was thinking either multiple SELECT statements or a >>> TRAVERSE statement. >>> >>> This query needs to be extremely fast, since it will be used a lot! :) >>> >>> Let me know your thoughts! >>> >> -- > > --- > You received this message because you are subscribed to the Google Groups > "OrientDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to orient-database+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.