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