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