Limit operator

The limit operator stops producing rows after the specified row limit has been reached.

Syntax

limit <number>;

Example

Schema for the following examples
#!test[schema, commit]
define
  entity content owns id;
  entity page sub content,
    owns page-id,
    owns name;
  entity profile sub page,
    owns username;
  entity user sub profile,
    owns phone,
    owns karma;

  attribute id value string;
  attribute page-id sub id;
  attribute username sub page-id;
  attribute name value string;
  attribute phone value string;
  attribute karma value double;
attribute start-date, value date;
relation friendship relates friend @card(0..2), owns start-date;
user plays friendship:friend;

Match all friends of friends of a given person, sorted by the number of mutual friends, highest to lowest. Return first 10.

#!test[read]
match
  $user isa user, has username "<username>";
  friendship (friend: $user, friend: $friend);
  friendship (friend: $friend, friend: $possible-friend);
  not { friendship (friend: $user, friend: $possible-friend); };
reduce $num-mutuals = count($friend) groupby $possible-friend;
sort $num-mutuals desc;
limit 10;