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