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