blob: ee9c792c8f68a4875d3281a7cb94283ee53196e8 [file] [log] [blame]
Ian Maxon858061a2022-05-12 19:11:28 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/aql/js-sdk.md at 2022-05-12
4 | Rendered using Apache Maven Fluido Skin 1.7
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20220512" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; AsterixDB Javascript SDK</title>
13 <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
14 <link rel="stylesheet" href="../css/site.css" />
15 <link rel="stylesheet" href="../css/print.css" media="print" />
16 <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2022-05-12</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.8</li>
31 <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="../SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="../geo/quickstart.html" title="GIS Support Overview"><span class="none"></span>GIS Support Overview</a></li>
61 <li><a href="../geo/functions.html" title="GIS Functions"><span class="none"></span>GIS Functions</a></li>
62 <li><a href="../interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
63 <li><a href="../spatial_join.html" title="Support of Spatial Joins"><span class="none"></span>Support of Spatial Joins</a></li>
64 <li><a href="../sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
65 <li class="nav-header">Deprecated</li>
66 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
67 <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
68 <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
69</ul>
70 <hr />
71 <div id="poweredBy">
72 <div class="clear"></div>
73 <div class="clear"></div>
74 <div class="clear"></div>
75 <div class="clear"></div>
76<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
77 </div>
78 </div>
79 </div>
80 <div id="bodyColumn" class="span10" >
81<!--
82 ! Licensed to the Apache Software Foundation (ASF) under one
83 ! or more contributor license agreements. See the NOTICE file
84 ! distributed with this work for additional information
85 ! regarding copyright ownership. The ASF licenses this file
86 ! to you under the Apache License, Version 2.0 (the
87 ! "License"); you may not use this file except in compliance
88 ! with the License. You may obtain a copy of the License at
89 !
90 ! http://www.apache.org/licenses/LICENSE-2.0
91 !
92 ! Unless required by applicable law or agreed to in writing,
93 ! software distributed under the License is distributed on an
94 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
95 ! KIND, either express or implied. See the License for the
96 ! specific language governing permissions and limitations
97 ! under the License.
98 !-->
99<h1>AsterixDB Javascript SDK</h1>
100<div class="section">
101<h2><a name="Obtaining_and_Including"></a>Obtaining and Including</h2>
102<p><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/bindings/asterix-sdk-stable.js">Download</a> the javascript SDK and include it like any other javascript library by adding the following line in the appropriate HTML file:</p>
103
104<div>
105<div>
106<pre class="source">&lt;script src=&quot;path/to/asterix-sdk-stable.js&quot;&gt;&lt;/script&gt;
107</pre></div></div>
108</div>
109<div class="section">
110<h2><a name="Interactive_Demos"></a>Interactive Demos</h2>
111<p>There are two interactive demos that are available for download. Both of the demos illustrate how the javascript API would be used in an application:</p>
112<ul>
113
114<li><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/demos/tweetbook-demo.zip">Tweetbook Demo</a>: a contrived geo-spatial application dealing with artificial Tweets allowing spatial, temporal, and keyword-based filtering.</li>
115<li><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/demos/admaql101-demo.zip">ADM/AQL 101 Demo</a>: an interactive version of all of the examples that are provided in the following section.</li>
116</ul></div>
117<div class="section">
118<h2><a name="The_javascript_SDK:_by_example"></a>The javascript SDK: by example</h2>
119<p>In this section, we explore how to form AQL queries using the javascript SDK. The queries from <a href="primer.html">AsterixDB 101: An ADM and AQL Primer</a> are used as examples here. For each AQL statement, the equivalent javascript expression is shown below it, followed by the results of executing the query.</p>
120<div class="section">
121<h3><a name="Query_0-A_-_Exact-Match_Lookup"></a>Query 0-A - Exact-Match Lookup</h3>
122<div class="section">
123<div class="section">
124<div class="section">
125<h6><a name="AQL"></a>AQL</h6>
126
127<div>
128<div>
129<pre class="source">use dataverse TinySocial;
130
131for $user in dataset FacebookUsers
132where $user.id = 8
133return $user;
134</pre></div></div>
135</div>
136<div class="section">
137<h6><a name="JS"></a>JS</h6>
138
139<div>
140<div>
141<pre class="source">var expression0a = new FLWOGRExpression()
142 .ForClause(&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
143 .WhereClause(new AExpression(&quot;$user.id = 8&quot;))
144 .ReturnClause(&quot;$user&quot;);
145</pre></div></div>
146</div>
147<div class="section">
148<h6><a name="Results"></a>Results</h6>
149
150<div>
151<div>
152<pre class="source">{ &quot;id&quot;: { int32: 8 } , &quot;alias&quot;: &quot;Nila&quot;, &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;user-since&quot;: { datetime: 1199182200000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 3 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Plexlane&quot;, &quot;start-date&quot;: { date: 1267315200000}, &quot;end-date&quot;: null } ]} }
153</pre></div></div>
154</div></div></div></div>
155<div class="section">
156<h3><a name="Query_0-B_-_Range_Scan"></a>Query 0-B - Range Scan</h3>
157<div class="section">
158<div class="section">
159<div class="section">
160<h6><a name="AQL"></a>AQL</h6>
161
162<div>
163<div>
164<pre class="source">use dataverse TinySocial;
165
166for $user in dataset FacebookUsers
167where $user.id &gt;= 2 and $user.id &lt;= 4
168return $user;
169</pre></div></div>
170</div>
171<div class="section">
172<h6><a name="JS"></a>JS</h6>
173
174<div>
175<div>
176<pre class="source">var expression0b = new FLWOGRExpression()
177 .ForClause(&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
178 .WhereClause().and(new AExpression(&quot;$user.id &gt;= 2&quot;), new AExpression(&quot;$user.id &lt;= 4&quot;))
179 .ReturnClause(&quot;$user&quot;);
180</pre></div></div>
181</div>
182<div class="section">
183<h6><a name="Results"></a>Results</h6>
184
185<div>
186<div>
187<pre class="source">{ &quot;id&quot;: { int32: 2 } , &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;user-since&quot;: { datetime: 1295691000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Hexviafind&quot;, &quot;start-date&quot;: { date: 1272326400000}, &quot;end-date&quot;: null } ]} }
188{ &quot;id&quot;: { int32: 3 } , &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;user-since&quot;: { datetime: 1341915000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;geomedia&quot;, &quot;start-date&quot;: { date: 1276732800000}, &quot;end-date&quot;: { date: 1264464000000} } ]} }
189{ &quot;id&quot;: { int32: 4 } , &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;user-since&quot;: { datetime: 1293444600000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 2 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Zamcorporation&quot;, &quot;start-date&quot;: { date: 1275955200000}, &quot;end-date&quot;: null } ]} }
190</pre></div></div>
191</div></div></div></div>
192<div class="section">
193<h3><a name="Query_1_-_Other_Query_Filters"></a>Query 1 - Other Query Filters</h3>
194<div class="section">
195<div class="section">
196<div class="section">
197<h6><a name="AQL"></a>AQL</h6>
198
199<div>
200<div>
201<pre class="source">use dataverse TinySocial;
202
203for $user in dataset FacebookUsers
204where $user.user-since &gt;= datetime('2010-07-22T00:00:00')
205and $user.user-since &lt;= datetime('2012-07-29T23:59:59')
206return $user;
207</pre></div></div>
208</div>
209<div class="section">
210<h6><a name="JS"></a>JS</h6>
211
212<div>
213<div>
214<pre class="source">var expression1 = new FLWOGRExpression()
215 .ForClause(&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
216 .WhereClause().and(
217 new AExpression(&quot;$user.user-since &gt;= datetime('2010-07-22T00:00:00')&quot;),
218 new AExpression(&quot;$user.user-since &lt;= datetime('2012-07-29T23:59:59')&quot;)
219 ).ReturnClause(&quot;$user&quot;);
220</pre></div></div>
221</div>
222<div class="section">
223<h6><a name="Results"></a>Results</h6>
224
225<div>
226<div>
227<pre class="source">{ &quot;id&quot;: { int32: 2 } , &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;user-since&quot;: { datetime: 1295691000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Hexviafind&quot;, &quot;start-date&quot;: { date: 1272326400000}, &quot;end-date&quot;: null } ]} }
228{ &quot;id&quot;: { int32: 10 } , &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;user-since&quot;: { datetime: 1287223800000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;physcane&quot;, &quot;start-date&quot;: { date: 1181001600000}, &quot;end-date&quot;: { date: 1320451200000} } ]} }
229{ &quot;id&quot;: { int32: 3 } , &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;user-since&quot;: { datetime: 1341915000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;geomedia&quot;, &quot;start-date&quot;: { date: 1276732800000}, &quot;end-date&quot;: { date: 1264464000000} } ]} }
230{ &quot;id&quot;: { int32: 4 } , &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;user-since&quot;: { datetime: 1293444600000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 2 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Zamcorporation&quot;, &quot;start-date&quot;: { date: 1275955200000}, &quot;end-date&quot;: null } ]} }
231</pre></div></div>
232</div></div></div></div>
233<div class="section">
234<h3><a name="Query_2-A_-_Equijoin"></a>Query 2-A - Equijoin</h3>
235<div class="section">
236<div class="section">
237<div class="section">
238<h6><a name="AQL"></a>AQL</h6>
239
240<div>
241<div>
242<pre class="source">use dataverse TinySocial;
243
244for $user in dataset FacebookUsers
245for $message in dataset FacebookMessages
246where $message.author-id = $user.id
247return {
248 &quot;uname&quot;: $user.name,
249 &quot;message&quot;: $message.message
250};
251</pre></div></div>
252</div>
253<div class="section">
254<h6><a name="JS"></a>JS</h6>
255
256<div>
257<div>
258<pre class="source">var expression2a = new FLWOGRExpression()
259 .ForClause (&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
260 .ForClause (&quot;$message&quot;, new AExpression(&quot;dataset FacebookMessages&quot;))
261 .WhereClause(new AExpression(&quot;$message.author-id = $user.id&quot;))
262 .ReturnClause({
263 &quot;uname&quot; : &quot;$user.name&quot;,
264 &quot;message&quot; : &quot;$message.message&quot;
265 });
266</pre></div></div>
267</div>
268<div class="section">
269<h6><a name="Results"></a>Results</h6>
270
271<div>
272<div>
273<pre class="source">{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot; }
274{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot; }
275{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot; }
276{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot; }
277{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot; }
278{ &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-y the plan is amazing&quot; }
279{ &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot; }
280{ &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;message&quot;: &quot; love acast its 3G is good:)&quot; }
281{ &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; dislike x-phone the voice-command is bad:(&quot; }
282{ &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; can't stand product-z its voicemail-service is OMG:(&quot; }
283{ &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love product-b its shortcut-menu is awesome:)&quot; }
284{ &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love ccast its wireless is good&quot; }
285{ &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;message&quot;: &quot; love product-b the customization is mind-blowing&quot; }
286{ &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;message&quot;: &quot; like x-phone the voicemail-service is awesome&quot; }
287{ &quot;uname&quot;: &quot;VonKemble&quot;, &quot;message&quot;: &quot; dislike product-b the speed is horrible&quot; }
288</pre></div></div>
289</div></div></div></div>
290<div class="section">
291<h3><a name="Query_2-B_-_Index_join"></a>Query 2-B - Index join</h3>
292<div class="section">
293<div class="section">
294<div class="section">
295<h6><a name="AQL"></a>AQL</h6>
296
297<div>
298<div>
299<pre class="source">use dataverse TinySocial;
300
301for $user in dataset FacebookUsers
302for $message in dataset FacebookMessages
303where $message.author-id /*+ indexnl */ = $user.id
304return {
305 &quot;uname&quot;: $user.name,
306 &quot;message&quot;: $message.message
307};
308</pre></div></div>
309</div>
310<div class="section">
311<h6><a name="JS"></a>JS</h6>
312
313<div>
314<div>
315<pre class="source">var expression2b = new FLWOGRExpression()
316 .ForClause (&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
317 .ForClause (&quot;$message&quot;, new AExpression(&quot;dataset FacebookMessages&quot;))
318 .WhereClause(new AExpression(&quot;$message.author-id /*+ indexnl */ = $user.id&quot;))
319 .ReturnClause({
320 &quot;uname&quot; : &quot;$user.name&quot;,
321 &quot;message&quot; : &quot;$message.message&quot;
322 });
323</pre></div></div>
324</div>
325<div class="section">
326<h6><a name="Results"></a>Results</h6>
327
328<div>
329<div>
330<pre class="source">{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot; }
331{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot; }
332{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot; }
333{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot; }
334{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot; }
335{ &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-y the plan is amazing&quot; }
336{ &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot; }
337{ &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;message&quot;: &quot; love acast its 3G is good:)&quot; }
338{ &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; dislike x-phone the voice-command is bad:(&quot; }
339{ &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; can't stand product-z its voicemail-service is OMG:(&quot; }
340{ &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love product-b its shortcut-menu is awesome:)&quot; }
341{ &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love ccast its wireless is good&quot; }
342{ &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;message&quot;: &quot; love product-b the customization is mind-blowing&quot; }
343{ &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;message&quot;: &quot; like x-phone the voicemail-service is awesome&quot; }
344{ &quot;uname&quot;: &quot;VonKemble&quot;, &quot;message&quot;: &quot; dislike product-b the speed is horrible&quot; }
345</pre></div></div>
346</div></div></div></div>
347<div class="section">
348<h3><a name="Query_3_-_Nested_Outer_Join"></a>Query 3 - Nested Outer Join</h3>
349<div class="section">
350<div class="section">
351<div class="section">
352<h6><a name="AQL"></a>AQL</h6>
353
354<div>
355<div>
356<pre class="source">use dataverse TinySocial;
357
358for $user in dataset FacebookUsers
359return {
360 &quot;uname&quot;: $user.name,
361 &quot;messages&quot;: for $message in dataset FacebookMessages
362 where $message.author-id = $user.id
363 return $message.message
364};
365</pre></div></div>
366</div>
367<div class="section">
368<h6><a name="JS"></a>JS</h6>
369
370<div>
371<div>
372<pre class="source">var expression3messages = new FLWOGRExpression()
373 .ForClause(&quot;$message&quot;, new AExpression(&quot;dataset FacebookMessages&quot;))
374 .WhereClause(new AExpression(&quot;$message.author-id = $user.id&quot;))
375 .ReturnClause(&quot;$message.message&quot;);
376
377var expression3 = new FLWOGRExpression()
378 .ForClause (&quot;$user&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
379 .ReturnClause({
380 &quot;uname&quot;: &quot;$user.name&quot;,
381 &quot;messages&quot; : expression3messages
382 });
383</pre></div></div>
384</div>
385<div class="section">
386<h6><a name="Results"></a>Results</h6>
387
388<div>
389<div>
390<pre class="source">{ &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;messages&quot;: { orderedlist: [&quot; dislike x-phone its touch-screen is horrible&quot;, &quot; like ccast the 3G is awesome:)&quot;, &quot; can't stand product-w the touch-screen is terrible&quot;, &quot; can't stand acast the network is horrible:(&quot;, &quot; can't stand acast its plan is terrible&quot; ]} }
391{ &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;messages&quot;: { orderedlist: [&quot; like product-y the plan is amazing&quot;, &quot; like product-z its platform is mind-blowing&quot; ]} }
392{ &quot;uname&quot;: &quot;NilaMilliron&quot;, &quot;messages&quot;: { orderedlist: [ ]} }
393{ &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;messages&quot;: { orderedlist: [&quot; love acast its 3G is good:)&quot; ]} }
394{ &quot;uname&quot;: &quot;BramHatch&quot;, &quot;messages&quot;: { orderedlist: [&quot; dislike x-phone the voice-command is bad:(&quot;, &quot; can't stand product-z its voicemail-service is OMG:(&quot; ]} }
395{ &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;messages&quot;: { orderedlist: [&quot; love product-b its shortcut-menu is awesome:)&quot;, &quot; love ccast its wireless is good&quot; ]} }
396{ &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;messages&quot;: { orderedlist: [&quot; love product-b the customization is mind-blowing&quot; ]} }
397{ &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;messages&quot;: { orderedlist: [&quot; like x-phone the voicemail-service is awesome&quot; ]} }
398{ &quot;uname&quot;: &quot;NicholasStroh&quot;, &quot;messages&quot;: { orderedlist: [ ]} }
399{ &quot;uname&quot;: &quot;VonKemble&quot;, &quot;messages&quot;: { orderedlist: [&quot; dislike product-b the speed is horrible&quot; ]} }
400</pre></div></div>
401</div></div></div></div>
402<div class="section">
403<h3><a name="Query_4_-_Theta_Join"></a>Query 4 - Theta Join</h3>
404<div class="section">
405<div class="section">
406<div class="section">
407<h6><a name="AQL"></a>AQL</h6>
408
409<div>
410<div>
411<pre class="source">use dataverse TinySocial;
412
413for $t in dataset TweetMessages
414return {
415 &quot;message&quot;: $t.message-text,
416 &quot;nearby-messages&quot;: for $t2 in dataset TweetMessages
417 where spatial-distance($t.sender-location, $t2.sender-location) &lt;= 1
418 return { &quot;msgtxt&quot;:$t2.message-text}
419};
420</pre></div></div>
421</div>
422<div class="section">
423<h6><a name="JS"></a>JS</h6>
424
425<div>
426<div>
427<pre class="source">var expression4messages = new FLWOGRExpression()
428 .ForClause( &quot;$t2&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
429 .WhereClause( new AExpression(&quot;spatial-distance($t.sender-location, $t2.sender-location) &lt;= 1&quot;))
430 .ReturnClause({ &quot;msgtxt&quot; : &quot;$t2.message-text&quot; });
431
432var expression4 = new FLWOGRExpression()
433 .ForClause( &quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
434 .ReturnClause({
435 &quot;message&quot; : &quot;$t.message-text&quot;,
436 &quot;nearby-messages&quot; : expression4messages
437 });
438</pre></div></div>
439</div>
440<div class="section">
441<h6><a name="Results"></a>Results</h6>
442
443<div>
444<div>
445<pre class="source">{ &quot;message&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot; }, { &quot;msgtxt&quot;: &quot; like product-w the speed is good:)&quot; } ]} }
446{ &quot;message&quot;: &quot; like x-phone the voice-clarity is good:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like x-phone the voice-clarity is good:)&quot; } ]} }
447{ &quot;message&quot;: &quot; like product-y the platform is good&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like product-y the platform is good&quot; } ]} }
448{ &quot;message&quot;: &quot; love product-z its customization is good:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; love product-z its customization is good:)&quot; } ]} }
449{ &quot;message&quot;: &quot; like product-y the voice-command is amazing:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like product-y the voice-command is amazing:)&quot; } ]} }
450{ &quot;message&quot;: &quot; like product-w the speed is good:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot; }, { &quot;msgtxt&quot;: &quot; like product-w the speed is good:)&quot; } ]} }
451{ &quot;message&quot;: &quot; love ccast its voicemail-service is awesome&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; love ccast its voicemail-service is awesome&quot; } ]} }
452{ &quot;message&quot;: &quot; can't stand product-w its speed is terrible:(&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; can't stand product-w its speed is terrible:(&quot; } ]} }
453{ &quot;message&quot;: &quot; like product-z the shortcut-menu is awesome:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like product-z the shortcut-menu is awesome:)&quot; } ]} }
454{ &quot;message&quot;: &quot; can't stand x-phone its platform is terrible&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; can't stand x-phone its platform is terrible&quot; } ]} }
455{ &quot;message&quot;: &quot; like ccast its shortcut-menu is awesome:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like ccast its shortcut-menu is awesome:)&quot; } ]} }
456{ &quot;message&quot;: &quot; like product-b the voice-command is mind-blowing:)&quot;, &quot;nearby-messages&quot;: { orderedlist: [{ &quot;msgtxt&quot;: &quot; like product-b the voice-command is mind-blowing:)&quot; } ]} }
457</pre></div></div>
458</div></div></div></div>
459<div class="section">
460<h3><a name="Query_5_-_Fuzzy_Join"></a>Query 5 - Fuzzy Join</h3>
461<div class="section">
462<div class="section">
463<div class="section">
464<h6><a name="AQL"></a>AQL</h6>
465<p>use dataverse TinySocial;</p>
466
467<div>
468<div>
469<pre class="source">set simfunction &quot;edit-distance&quot;;
470set simthreshold &quot;3&quot;;
471
472for $fbu in dataset FacebookUsers
473return {
474 &quot;id&quot;: $fbu.id,
475 &quot;name&quot;: $fbu.name,
476 &quot;similar-users&quot;: for $t in dataset TweetMessages
477 let $tu := $t.user
478 where $tu.name ~= $fbu.name
479 return {
480 &quot;twitter-screenname&quot;: $tu.screen-name,
481 &quot;twitter-name&quot;: $tu.name
482 }
483};
484</pre></div></div>
485</div>
486<div class="section">
487<h6><a name="JS"></a>JS</h6>
488
489<div>
490<div>
491<pre class="source">var similarUsersExpression = new FLWOGRExpression()
492 .ForClause(&quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
493 .LetClause (&quot;$tu&quot;, new AExpression(&quot;$t.user&quot;))
494 .WhereClause(new AExpression(&quot;$tu.name ~= $fbu.name&quot;))
495 .ReturnClause({
496 &quot;twitter-screenname&quot;: &quot;$tu.screen-name&quot;,
497 &quot;twitter-name&quot;: &quot;$tu.name&quot;
498 });
499
500var expression5 = new FLWOGRExpression()
501 .ForClause (&quot;$fbu&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
502 .ReturnClause(
503 {
504 &quot;id&quot; : &quot;$fbu.id&quot;,
505 &quot;name&quot; : &quot;$fbu.name&quot;,
506 &quot;similar-users&quot; : similarUsersExpression
507 }
508 );
509</pre></div></div>
510</div>
511<div class="section">
512<h6><a name="Results"></a>Results</h6>
513
514<div>
515<div>
516<pre class="source">{ &quot;id&quot;: { int32: 1 } , &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
517{ &quot;id&quot;: { int32: 2 } , &quot;name&quot;: &quot;IsbelDull&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
518{ &quot;id&quot;: { int32: 8 } , &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;similar-users&quot;: { orderedlist: [{ &quot;twitter-screenname&quot;: &quot;NilaMilliron_tw&quot;, &quot;twitter-name&quot;: &quot;Nila Milliron&quot; } ]} }
519{ &quot;id&quot;: { int32: 9 } , &quot;name&quot;: &quot;WoodrowNehling&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
520{ &quot;id&quot;: { int32: 10 } , &quot;name&quot;: &quot;BramHatch&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
521{ &quot;id&quot;: { int32: 3 } , &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
522{ &quot;id&quot;: { int32: 6 } , &quot;name&quot;: &quot;WillisWynne&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
523{ &quot;id&quot;: { int32: 7 } , &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
524{ &quot;id&quot;: { int32: 4 } , &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
525{ &quot;id&quot;: { int32: 5 } , &quot;name&quot;: &quot;VonKemble&quot;, &quot;similar-users&quot;: { orderedlist: [ ]} }
526</pre></div></div>
527</div></div></div></div>
528<div class="section">
529<h3><a name="Query_6_-_Existential_Quantification"></a>Query 6 - Existential Quantification</h3>
530<div class="section">
531<div class="section">
532<div class="section">
533<h6><a name="AQL"></a>AQL</h6>
534
535<div>
536<div>
537<pre class="source">use dataverse TinySocial;
538
539for $fbu in dataset FacebookUsers
540where (some $e in $fbu.employment satisfies is-null($e.end-date))
541return $fbu;
542</pre></div></div>
543</div>
544<div class="section">
545<h6><a name="JS"></a>JS</h6>
546
547<div>
548<div>
549<pre class="source">var expression6 = new FLWOGRExpression()
550 .ForClause (&quot;$fbu&quot;, new AQLClause().set(&quot;dataset FacebookUsers&quot;))
551 .WhereClause(
552 new QuantifiedExpression (
553 &quot;some&quot; ,
554 {&quot;$e&quot; : new AExpression(&quot;$fbu.employment&quot;) },
555 new FunctionExpression(&quot;is-null&quot;, new AExpression(&quot;$e.end-date&quot;))
556 )
557 )
558 .ReturnClause(&quot;$fbu&quot;);
559</pre></div></div>
560</div>
561<div class="section">
562<h6><a name="Results"></a>Results</h6>
563
564<div>
565<div>
566<pre class="source">{ &quot;id&quot;: { int32: 1 } , &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;user-since&quot;: { datetime: 1345457400000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 2 } , { int32: 3 } , { int32: 6 } , { int32: 10 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Codetechno&quot;, &quot;start-date&quot;: { date: 1154822400000}, &quot;end-date&quot;: null } ]} }
567{ &quot;id&quot;: { int32: 2 } , &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;user-since&quot;: { datetime: 1295691000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Hexviafind&quot;, &quot;start-date&quot;: { date: 1272326400000}, &quot;end-date&quot;: null } ]} }
568{ &quot;id&quot;: { int32: 8 } , &quot;alias&quot;: &quot;Nila&quot;, &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;user-since&quot;: { datetime: 1199182200000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 3 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Plexlane&quot;, &quot;start-date&quot;: { date: 1267315200000}, &quot;end-date&quot;: null } ]} }
569{ &quot;id&quot;: { int32: 6 } , &quot;alias&quot;: &quot;Willis&quot;, &quot;name&quot;: &quot;WillisWynne&quot;, &quot;user-since&quot;: { datetime: 1105956600000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 3 } , { int32: 7 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;jaydax&quot;, &quot;start-date&quot;: { date: 1242345600000}, &quot;end-date&quot;: null } ]} }
570{ &quot;id&quot;: { int32: 7 } , &quot;alias&quot;: &quot;Suzanna&quot;, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;user-since&quot;: { datetime: 1344334200000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 6 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Labzatron&quot;, &quot;start-date&quot;: { date: 1303171200000}, &quot;end-date&quot;: null } ]} }
571{ &quot;id&quot;: { int32: 4 } , &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;user-since&quot;: { datetime: 1293444600000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 2 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Zamcorporation&quot;, &quot;start-date&quot;: { date: 1275955200000}, &quot;end-date&quot;: null } ]} }
572{ &quot;id&quot;: { int32: 5 } , &quot;alias&quot;: &quot;Von&quot;, &quot;name&quot;: &quot;VonKemble&quot;, &quot;user-since&quot;: { datetime: 1262686200000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 3 } , { int32: 6 } , { int32: 10 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Kongreen&quot;, &quot;start-date&quot;: { date: 1290816000000}, &quot;end-date&quot;: null } ]} }
573</pre></div></div>
574</div></div></div></div>
575<div class="section">
576<h3><a name="Query_7_-_Universal_Quantification"></a>Query 7 - Universal Quantification</h3>
577<div class="section">
578<div class="section">
579<div class="section">
580<h6><a name="AQL"></a>AQL</h6>
581
582<div>
583<div>
584<pre class="source">use dataverse TinySocial;
585
586for $fbu in dataset FacebookUsers
587where (every $e in $fbu.employment satisfies not(is-null($e.end-date)))
588return $fbu;
589</pre></div></div>
590</div>
591<div class="section">
592<h6><a name="JS"></a>JS</h6>
593
594<div>
595<div>
596<pre class="source">var expression7 = new FLWOGRExpression()
597 .ForClause(&quot;$fbu&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
598 .WhereClause(
599 new QuantifiedExpression (
600 &quot;every&quot; ,
601 {&quot;$e&quot; : new AExpression(&quot;$fbu.employment&quot;) },
602 new FunctionExpression(&quot;not&quot;, new FunctionExpression(&quot;is-null&quot;, new AExpression(&quot;$e.end-date&quot;)))
603 )
604 )
605 .ReturnClause(&quot;$fbu&quot;);
606</pre></div></div>
607</div>
608<div class="section">
609<h6><a name="Results"></a>Results</h6>
610
611<div>
612<div>
613<pre class="source">{ &quot;id&quot;: { int32: 9 } , &quot;alias&quot;: &quot;Woodrow&quot;, &quot;name&quot;: &quot;WoodrowNehling&quot;, &quot;user-since&quot;: { datetime: 1127211000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 3 } , { int32: 10 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;Zuncan&quot;, &quot;start-date&quot;: { date: 1050969600000}, &quot;end-date&quot;: { date: 1260662400000} } ]} }
614{ &quot;id&quot;: { int32: 10 } , &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;user-since&quot;: { datetime: 1287223800000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;physcane&quot;, &quot;start-date&quot;: { date: 1181001600000}, &quot;end-date&quot;: { date: 1320451200000} } ]} }
615{ &quot;id&quot;: { int32: 3 } , &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;user-since&quot;: { datetime: 1341915000000}, &quot;friend-ids&quot;: { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, &quot;employment&quot;: { orderedlist: [{ &quot;organization-name&quot;: &quot;geomedia&quot;, &quot;start-date&quot;: { date: 1276732800000}, &quot;end-date&quot;: { date: 1264464000000} } ]} }
616</pre></div></div>
617</div></div></div></div>
618<div class="section">
619<h3><a name="Query_8_-_Simple_Aggregation"></a>Query 8 - Simple Aggregation</h3>
620<div class="section">
621<div class="section">
622<div class="section">
623<h6><a name="AQL"></a>AQL</h6>
624
625<div>
626<div>
627<pre class="source">use dataverse TinySocial;
628
629count(for $fbu in dataset FacebookUsers return $fbu);
630</pre></div></div>
631</div>
632<div class="section">
633<h6><a name="JS"></a>JS</h6>
634
635<div>
636<div>
637<pre class="source">var expression8 = new FunctionExpression(
638 &quot;count&quot;,
639 new FLWOGRExpression()
640 .ForClause(&quot;$fbu&quot;, new AExpression(&quot;dataset FacebookUsers&quot;))
641 .ReturnClause(&quot;$fbu&quot;)
642);
643</pre></div></div>
644</div>
645<div class="section">
646<h6><a name="Results"></a>Results</h6>
647
648<div>
649<div>
650<pre class="source">{ int64: 10 }
651</pre></div></div>
652</div></div></div></div>
653<div class="section">
654<h3><a name="Query_9-A_-_Grouping_and_Aggregation"></a>Query 9-A - Grouping and Aggregation</h3>
655<div class="section">
656<div class="section">
657<div class="section">
658<h6><a name="AQL"></a>AQL</h6>
659
660<div>
661<div>
662<pre class="source">use dataverse TinySocial;
663
664for $t in dataset TweetMessages
665group by $uid := $t.user.screen-name with $t
666return {
667 &quot;user&quot;: $uid,
668 &quot;count&quot;: count($t)
669};
670</pre></div></div>
671</div>
672<div class="section">
673<h6><a name="JS"></a>JS</h6>
674
675<div>
676<div>
677<pre class="source">var expression9a = new FLWOGRExpression()
678 .ForClause(&quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
679 .GroupClause(&quot;$uid&quot;, new AExpression(&quot;$t.user.screen-name&quot;), &quot;with&quot;, &quot;$t&quot;)
680 .ReturnClause(
681 {
682 &quot;user&quot; : &quot;$uid&quot;,
683 &quot;count&quot; : new FunctionExpression(&quot;count&quot;, new AExpression(&quot;$t&quot;))
684 }
685 );
686</pre></div></div>
687</div>
688<div class="section">
689<h6><a name="Results"></a>Results</h6>
690
691<div>
692<div>
693<pre class="source">{ &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: { int64: 3 } }
694{ &quot;user&quot;: &quot;OliJackson_512&quot;, &quot;count&quot;: { int64: 1 } }
695{ &quot;user&quot;: &quot;NilaMilliron_tw&quot;, &quot;count&quot;: { int64: 1 } }
696{ &quot;user&quot;: &quot;ChangEwing_573&quot;, &quot;count&quot;: { int64: 1 } }
697{ &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: { int64: 6 } }
698</pre></div></div>
699</div></div></div></div>
700<div class="section">
701<h3><a name="Query_9-B_-_.28Hash-Based.29_Grouping_and_Aggregation"></a>Query 9-B - (Hash-Based) Grouping and Aggregation</h3>
702<div class="section">
703<div class="section">
704<div class="section">
705<h6><a name="AQL"></a>AQL</h6>
706
707<div>
708<div>
709<pre class="source">use dataverse TinySocial;
710
711for $t in dataset TweetMessages
712/*+ hash*/
713group by $uid := $t.user.screen-name with $t
714return {
715 &quot;user&quot;: $uid,
716 &quot;count&quot;: count($t)
717};
718</pre></div></div>
719</div>
720<div class="section">
721<h6><a name="JS"></a>JS</h6>
722
723<div>
724<div>
725<pre class="source">var expression9b = new FLWOGRExpression()
726 .ForClause(&quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
727 .AQLClause(&quot;/*+ hash*/&quot;)
728 .GroupClause(&quot;$uid&quot;, new AExpression(&quot;$t.user.screen-name&quot;), &quot;with&quot;, &quot;$t&quot;)
729 .ReturnClause(
730 {
731 &quot;user&quot; : &quot;$uid&quot;,
732 &quot;count&quot; : new FunctionExpression(&quot;count&quot;, new AExpression(&quot;$t&quot;))
733 }
734 );
735</pre></div></div>
736</div>
737<div class="section">
738<h6><a name="Results"></a>Results</h6>
739
740<div>
741<div>
742<pre class="source">{ &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: { int64: 3 } }
743{ &quot;user&quot;: &quot;OliJackson_512&quot;, &quot;count&quot;: { int64: 1 } }
744{ &quot;user&quot;: &quot;NilaMilliron_tw&quot;, &quot;count&quot;: { int64: 1 } }
745{ &quot;user&quot;: &quot;ChangEwing_573&quot;, &quot;count&quot;: { int64: 1 } }
746{ &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: { int64: 6 } }
747</pre></div></div>
748</div></div></div></div>
749<div class="section">
750<h3><a name="Query_10_-_Grouping_and_Limits"></a>Query 10 - Grouping and Limits</h3>
751<div class="section">
752<div class="section">
753<div class="section">
754<h6><a name="AQL"></a>AQL</h6>
755
756<div>
757<div>
758<pre class="source">use dataverse TinySocial;
759
760for $t in dataset TweetMessages
761group by $uid := $t.user.screen-name with $t
762let $c := count($t)
763order by $c desc
764limit 3
765return {
766 &quot;user&quot;: $uid,
767 &quot;count&quot;: $c
768};
769</pre></div></div>
770</div>
771<div class="section">
772<h6><a name="JS"></a>JS</h6>
773
774<div>
775<div>
776<pre class="source">var expression10 = new FLWOGRExpression()
777 .ForClause(&quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
778 .GroupClause(&quot;$uid&quot;, new AExpression(&quot;$t.user.screen-name&quot;), &quot;with&quot;, &quot;$t&quot;)
779 .LetClause(&quot;$c&quot;, new FunctionExpression(&quot;count&quot;, new AExpression(&quot;$t&quot;)))
780 .OrderbyClause( new AExpression(&quot;$c&quot;), &quot;desc&quot; )
781 .LimitClause(new AExpression(&quot;3&quot;))
782 .ReturnClause(
783 {
784 &quot;user&quot; : &quot;$uid&quot;,
785 &quot;count&quot; : &quot;$c&quot;
786 }
787 );
788</pre></div></div>
789</div>
790<div class="section">
791<h6><a name="Results"></a>Results</h6>
792
793<div>
794<div>
795<pre class="source">{ &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: { int64: 6 } }
796{ &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: { int64: 3 } }
797{ &quot;user&quot;: &quot;NilaMilliron_tw&quot;, &quot;count&quot;: { int64: 1 } }
798</pre></div></div>
799</div></div></div></div>
800<div class="section">
801<h3><a name="Query_11_-_Left_Outer_Fuzzy_Join"></a>Query 11 - Left Outer Fuzzy Join</h3>
802<div class="section">
803<div class="section">
804<div class="section">
805<h6><a name="AQL"></a>AQL</h6>
806
807<div>
808<div>
809<pre class="source">use dataverse TinySocial;
810
811set simfunction &quot;jaccard&quot;;
812set simthreshold &quot;0.3&quot;;
813
814for $t in dataset TweetMessages
815return {
816 &quot;tweet&quot;: $t,
817 &quot;similar-tweets&quot;: for $t2 in dataset TweetMessages
818 where $t2.referred-topics ~= $t.referred-topics
819 and $t2.tweetid != $t.tweetid
820 return $t2.referred-topics
821};
822</pre></div></div>
823</div>
824<div class="section">
825<h6><a name="JS"></a>JS</h6>
826
827<div>
828<div>
829<pre class="source">var expression11 = new FLWOGRExpression()
830 .ForClause( &quot;$t&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
831 .ReturnClause({
832 &quot;tweet&quot; : new AExpression(&quot;$t&quot;),
833 &quot;similar-tweets&quot;: new FLWOGRExpression()
834 .ForClause( &quot;$t2&quot;, new AExpression(&quot;dataset TweetMessages&quot;))
835 .WhereClause().and(
836 new AExpression(&quot;$t2.referred-topics ~= $t.referred-topics&quot;),
837 new AExpression(&quot;$t2.tweetid != $t.tweetid&quot;)
838 )
839 .ReturnClause(&quot;$t2.referred-topics&quot;)
840 });
841</pre></div></div>
842</div>
843<div class="section">
844<h6><a name="Results"></a>Results</h6>
845
846<div>
847<div>
848<pre class="source">{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;10&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 121 } , &quot;statuses_count&quot;: { int32: 362 } , &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followers_count&quot;: { int32: 17159 } }, &quot;sender-location&quot;: { point: [29.15, 76.53]}, &quot;send-time&quot;: { datetime: 1201342200000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;ccast&quot;, &quot;voice-clarity&quot; ]}, &quot;message-text&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;x-phone&quot;, &quot;voice-clarity&quot; ]}, { unorderedlist: [&quot;ccast&quot;, &quot;shortcut-menu&quot; ]}, { unorderedlist: [&quot;ccast&quot;, &quot;voicemail-service&quot; ]} ]} }
849{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;6&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 121 } , &quot;statuses_count&quot;: { int32: 362 } , &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followers_count&quot;: { int32: 17159 } }, &quot;sender-location&quot;: { point: [47.51, 83.99]}, &quot;send-time&quot;: { datetime: 1273227000000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;x-phone&quot;, &quot;voice-clarity&quot; ]}, &quot;message-text&quot;: &quot; like x-phone the voice-clarity is good:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;ccast&quot;, &quot;voice-clarity&quot; ]}, { unorderedlist: [&quot;x-phone&quot;, &quot;platform&quot; ]} ]} }
850{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;7&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;ChangEwing_573&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 182 } , &quot;statuses_count&quot;: { int32: 394 } , &quot;name&quot;: &quot;Chang Ewing&quot;, &quot;followers_count&quot;: { int32: 32136 } }, &quot;sender-location&quot;: { point: [36.21, 72.6]}, &quot;send-time&quot;: { datetime: 1314267000000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-y&quot;, &quot;platform&quot; ]}, &quot;message-text&quot;: &quot; like product-y the platform is good&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;x-phone&quot;, &quot;platform&quot; ]}, { unorderedlist: [&quot;product-y&quot;, &quot;voice-command&quot; ]} ]} }
851{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;1&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [47.44, 80.65]}, &quot;send-time&quot;: { datetime: 1209204600000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-z&quot;, &quot;customization&quot; ]}, &quot;message-text&quot;: &quot; love product-z its customization is good:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-z&quot;, &quot;shortcut-menu&quot; ]} ]} }
852{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;12&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;OliJackson_512&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 445 } , &quot;statuses_count&quot;: { int32: 164 } , &quot;name&quot;: &quot;Oli Jackson&quot;, &quot;followers_count&quot;: { int32: 22649 } }, &quot;sender-location&quot;: { point: [24.82, 94.63]}, &quot;send-time&quot;: { datetime: 1266055800000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-y&quot;, &quot;voice-command&quot; ]}, &quot;message-text&quot;: &quot; like product-y the voice-command is amazing:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-y&quot;, &quot;platform&quot; ]}, { unorderedlist: [&quot;product-b&quot;, &quot;voice-command&quot; ]} ]} }
853{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;3&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [29.72, 75.8]}, &quot;send-time&quot;: { datetime: 1162635000000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-w&quot;, &quot;speed&quot; ]}, &quot;message-text&quot;: &quot; like product-w the speed is good:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-w&quot;, &quot;speed&quot; ]} ]} }
854{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;9&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [36.86, 74.62]}, &quot;send-time&quot;: { datetime: 1342865400000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;ccast&quot;, &quot;voicemail-service&quot; ]}, &quot;message-text&quot;: &quot; love ccast its voicemail-service is awesome&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;ccast&quot;, &quot;voice-clarity&quot; ]}, { unorderedlist: [&quot;ccast&quot;, &quot;shortcut-menu&quot; ]} ]} }
855{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;5&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [40.09, 92.69]}, &quot;send-time&quot;: { datetime: 1154686200000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-w&quot;, &quot;speed&quot; ]}, &quot;message-text&quot;: &quot; can't stand product-w its speed is terrible:(&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-w&quot;, &quot;speed&quot; ]} ]} }
856{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;8&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [46.05, 93.34]}, &quot;send-time&quot;: { datetime: 1129284600000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-z&quot;, &quot;shortcut-menu&quot; ]}, &quot;message-text&quot;: &quot; like product-z the shortcut-menu is awesome:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;ccast&quot;, &quot;shortcut-menu&quot; ]}, { unorderedlist: [&quot;product-z&quot;, &quot;customization&quot; ]} ]} }
857{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;11&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NilaMilliron_tw&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 445 } , &quot;statuses_count&quot;: { int32: 164 } , &quot;name&quot;: &quot;Nila Milliron&quot;, &quot;followers_count&quot;: { int32: 22649 } }, &quot;sender-location&quot;: { point: [37.59, 68.42]}, &quot;send-time&quot;: { datetime: 1205057400000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;x-phone&quot;, &quot;platform&quot; ]}, &quot;message-text&quot;: &quot; can't stand x-phone its platform is terrible&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;x-phone&quot;, &quot;voice-clarity&quot; ]}, { unorderedlist: [&quot;product-y&quot;, &quot;platform&quot; ]} ]} }
858{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;2&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 121 } , &quot;statuses_count&quot;: { int32: 362 } , &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followers_count&quot;: { int32: 17159 } }, &quot;sender-location&quot;: { point: [32.84, 67.14]}, &quot;send-time&quot;: { datetime: 1273745400000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;ccast&quot;, &quot;shortcut-menu&quot; ]}, &quot;message-text&quot;: &quot; like ccast its shortcut-menu is awesome:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-z&quot;, &quot;shortcut-menu&quot; ]}, { unorderedlist: [&quot;ccast&quot;, &quot;voice-clarity&quot; ]}, { unorderedlist: [&quot;ccast&quot;, &quot;voicemail-service&quot; ]} ]} }
859{ &quot;tweet&quot;: { &quot;tweetid&quot;: &quot;4&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: { int32: 39339 } , &quot;statuses_count&quot;: { int32: 473 } , &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: { int32: 49416 } }, &quot;sender-location&quot;: { point: [39.28, 70.48]}, &quot;send-time&quot;: { datetime: 1324894200000}, &quot;referred-topics&quot;: { unorderedlist: [&quot;product-b&quot;, &quot;voice-command&quot; ]}, &quot;message-text&quot;: &quot; like product-b the voice-command is mind-blowing:)&quot; }, &quot;similar-tweets&quot;: { orderedlist: [{ unorderedlist: [&quot;product-y&quot;, &quot;voice-command&quot; ]} ]} }
860</pre></div></div></div></div></div></div></div>
861 </div>
862 </div>
863 </div>
864 <hr/>
865 <footer>
866 <div class="container-fluid">
867 <div class="row-fluid">
868<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
869 feather logo, and the Apache AsterixDB project logo are either
870 registered trademarks or trademarks of The Apache Software
871 Foundation in the United States and other countries.
872 All other marks mentioned may be trademarks or registered
873 trademarks of their respective owners.
874 </div>
875 </div>
876 </div>
877 </footer>
878 </body>
879</html>