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