blob: 7ad27aebe50cb8c54d38e01eefca63e1c42c5222 [file] [log] [blame]
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -07001<!DOCTYPE html>
2
3<html>
4<head>
5 <title>AsterixDB TinySocial Demo</title>
6
7 <style>
8 .pretty-printed {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -07009 background-color: #eeeeee;
10 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070011 }
12
13 .how-to-run {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070014 background-color: #c8c8c8;
15 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070016 }
17
18 .result-output {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070019 background-color: #BED8E5;
20 margin-bottom: 1em;
21 overflow-x: scroll;
22 overflow-y: none;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070023 }
24
25 body {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070026 font-family : "Helvetica";
27 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070028 }
29 </style>
30
31 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
32 <script src="../js/asterix-sdk-stable.js"></script>
33 <script src="js/demo.js"></script>
34</head>
35<body>
36 <h1>AQL: Querying TinySocial AsterixDB</h1>
37
38 <h2>Query 0-A - Exact-Match Lookup</h2>
39 <div class="sample-query">
40
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070041 <div class="pretty-printed"><pre>
42 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070043
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070044 for $user in dataset FacebookUsers
45 where $user.id = 8
46 return $user;
47 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070048
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070049 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070050 var expression0a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070051 .ForClause("$user", new AExpression("dataset FacebookUsers"))
52 .WhereClause(new AExpression("$user.id = 8"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070053 .ReturnClause("$user");
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070054 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070055
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070056 <div class="result-output" id="result0a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070057 </div>
58
59 <button id="run0a">Run #0-A</button>
60 </div>
61 <hr/>
62 <h2>Query 0-B - Range Scan</h2>
63 <div class="sample-query">
64
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070065 <div class="pretty-printed"><pre>
66 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070067
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070068 for $user in dataset FacebookUsers
69 where $user.id >= 2 and $user.id <= 4
70 return $user;
71 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070072
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070073 <div class="how-to-run"><pre><code class="javascript">
74 var expression0b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070075 .ForClause("$user", new AExpression("dataset FacebookUsers"))
76 .WhereClause().and(new AExpression("$user.id >= 2"), new AExpression("$user.id <= 4"))
77 .ReturnClause("$user");
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070078 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070079
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070080 <div class="result-output" id="result0b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070081 </div>
82
83 <button id="run0b">Run #0-B</button>
84 </div>
85 <hr/>
86
87 <h2>Query 1 - Other Query Filters</h2>
88 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070089 <div class="pretty-printed"><pre>
90 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070091
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070092 for $user in dataset FacebookUsers
93 where $user.user-since >= datetime('2010-07-22T00:00:00')
94 and $user.user-since <= datetime('2012-07-29T23:59:59')
95 return $user;
96 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070097
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070098 <div class="how-to-run"><pre><code class="javascript">
99 var expression1 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700100 .ForClause("$user", new AExpression("dataset FacebookUsers"))
101 .WhereClause().and(
102 new AExpression("$user.user-since >= datetime('2010-07-22T00:00:00')"),
103 new AExpression("$user.user-since <= datetime('2012-07-29T23:59:59')")
104 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700105 .ReturnClause("$user");
106 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700107
108 <div class="result-output" id="result1">
109 </div>
110
111 <button id="run1">Run #1</button>
112 </div>
113 <hr/>
114
115 <h2>Query 2-A - Equijoin</h2>
116 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700117 <div class="pretty-printed"><pre>
118 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700119
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700120 for $user in dataset FacebookUsers
121 for $message in dataset FacebookMessages
122 where $message.author-id = $user.id
123 return {
124 "uname": $user.name,
125 "message": $message.message
126 };
127 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700128
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700129 <div class="how-to-run"><pre><code class="javascript">
130 var expression2a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700131 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
132 .ForClause ("$message", new AExpression("dataset FacebookMessages"))
133 .WhereClause(new AExpression("$message.author-id = $user.id"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700134 .ReturnClause({
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700135 "uname" : "$user.name",
136 "message" : "$message.message"
137 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700138 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700139
140 <div class="result-output" id="result2a">
141 </div>
142
143 <button id="run2a">Run #2-A</button>
144 </div>
145 <hr/>
146
147 <h2>Query 2-B - Index join</h2>
148 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700149 <div class="pretty-printed"><pre>
150 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700151
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700152 for $user in dataset FacebookUsers
153 for $message in dataset FacebookMessages
154 where $message.author-id /*+ indexnl */ = $user.id
155 return {
156 "uname": $user.name,
157 "message": $message.message
158 };
159 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700160
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700161 <div class="how-to-run"><pre><code class="javascript">
162 var expression2b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700163 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
164 .ForClause ("$message", new AExpression("dataset FacebookMessages"))
165 .WhereClause(new AExpression("$message.author-id /*+ indexnl */ = $user.id"))
166 .ReturnClause({
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700167 "uname" : "$user.name",
168 "message" : "$message.message"
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700169 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700170 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700171
172 <div class="result-output" id="result2b">
173 </div>
174
175 <button id="run2b">Run #2-B</button>
176 </div>
177 <hr/>
178
179 <h2>Query 3 - Nested Outer Join</h2>
180 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700181 <div class="pretty-printed"><pre>
182 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700183
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700184 for $user in dataset FacebookUsers
185 return {
186 "uname": $user.name,
187 "messages": for $message in dataset FacebookMessages
188 where $message.author-id = $user.id
189 return $message.message
190 };
191 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700192
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700193 <div class="how-to-run"><pre><code class="javascript">
194 var expression3messages = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700195 .ForClause("$message", new AExpression("dataset FacebookMessages"))
196 .WhereClause(new AExpression("$message.author-id = $user.id"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700197 .ReturnClause("$message.message");
198
199 var expression3 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700200 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700201 .ReturnClause({
202 "uname": "$user.name",
203 "messages" : expression3messages
204 });
205 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700206
207 <div class="result-output" id="result3">
208 </div>
209
210 <button id="run3">Run #3</button>
211 </div>
212 <hr/>
213
214 <h2>Query 4 - Theta Join</h2>
215 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700216 <div class="pretty-printed"><pre>
217 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700218
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700219 for $t in dataset TweetMessages
220 return {
221 "message": $t.message-text,
222 "nearby-messages": for $t2 in dataset TweetMessages
223 where spatial-distance($t.sender-location, $t2.sender-location) <= 1
224 return { "msgtxt":$t2.message-text}
225 };
226 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700227
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700228 <div class="how-to-run"><pre><code class="javascript">
229 var expression4messages = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700230 .ForClause( "$t2", new AExpression("dataset TweetMessages"))
231 .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700232 .ReturnClause({ "msgtxt" : "$t2.message-text" });
233
234 var expression4 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700235 .ForClause( "$t", new AExpression("dataset TweetMessages"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700236 .ReturnClause({
237 "message" : "$t.message-text",
238 "nearby-messages" : expression4messages
239 });
240 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700241
242 <div class="result-output" id="result4">
243 </div>
244
245 <button id="run4">Run #4</button>
246 </div>
247 <hr/>
248
249 <h2>Query 5 - Fuzzy Join</h2>
250 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700251 <div class="pretty-printed"><pre>
252 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700253
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700254 set simfunction "edit-distance";
255 set simthreshold "3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700256
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700257 for $fbu in dataset FacebookUsers
258 return {
259 "id": $fbu.id,
260 "name": $fbu.name,
261 "similar-users": for $t in dataset TweetMessages
262 let $tu := $t.user
263 where $tu.name ~= $fbu.name
264 return {
265 "twitter-screenname": $tu.screen-name,
266 "twitter-name": $tu.name
267 }
268 };
269 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700270
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700271 <div class="how-to-run"><pre><code class="javascript">
272 var similarUsersExpression = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700273 .ForClause("$t", new AExpression("dataset TweetMessages"))
274 .LetClause ("$tu", new AExpression("$t.user"))
275 .WhereClause(new AExpression("$tu.name ~= $fbu.name"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700276 .ReturnClause({
277 "twitter-screenname": "$tu.screen-name",
278 "twitter-name": "$tu.name"
279 });
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700280
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700281 var expression5 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700282 .ForClause ("$fbu", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700283 .ReturnClause(
284 {
285 "id" : "$fbu.id",
286 "name" : "$fbu.name",
287 "similar-users" : similarUsersExpression
288 }
289 );
290 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700291
292 <div class="result-output" id="result5">
293 </div>
294
295 <button id="run5">Run #5</button>
296 </div>
297 <hr/>
298
299 <h2>Query 6 - Existential Quantification</h2>
300 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700301 <div class="pretty-printed"><pre>
302 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700303
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700304 for $fbu in dataset FacebookUsers
305 where (some $e in $fbu.employment satisfies is-null($e.end-date))
306 return $fbu;
307 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700308
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700309 <div class="how-to-run"><pre><code class="javascript">
310 var expression6 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700311 .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers"))
312 .WhereClause(
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700313 new QuantifiedExpression (
314 "some" ,
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700315 {"$e" : new AExpression("$fbu.employment") },
316 new FunctionExpression("is-null", new AExpression("$e.end-date"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700317 )
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700318 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700319 .ReturnClause("$fbu");
320 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700321
322 <div class="result-output" id="result6">
323 </div>
324
325 <button id="run6">Run #6</button>
326 </div>
327 <hr/>
328
329 <h2>Query 7 - Universal Quantification</h2>
330 <div class="sample-query">
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700331 <div class="pretty-printed"><pre>
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700332 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700333
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700334 for $fbu in dataset FacebookUsers
335 where (every $e in $fbu.employment satisfies not(is-null($e.end-date)))
336 return $fbu;
337 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700338
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700339 <div class="how-to-run"><pre><code class="javascript">
340 var expression7 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700341 .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
342 .WhereClause(
343 new QuantifiedExpression (
344 "every" ,
345 {"$e" : new AExpression("$fbu.employment") },
346 new FunctionExpression("not", new FunctionExpression("is-null", new AExpression("$e.end-date")))
347 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700348 )
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700349 .ReturnClause("$fbu");
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700350 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700351
352 <div class="result-output" id="result7">
353 </div>
354
355 <button id="run7">Run #7</button>
356 </div>
357 <hr/>
358
359 <h2>Query 8 - Simple Aggregation</h2>
360 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700361 <div class="pretty-printed"><pre>
362 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700363
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700364 count(for $fbu in dataset FacebookUsers return $fbu);
365 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700366
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700367 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700368 var expression8 = new FunctionExpression(
369 "count",
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700370 new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700371 .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700372 .ReturnClause("$fbu")
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700373 );
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700374 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700375
376 <div class="result-output" id="result8">
377 </div>
378
379 <button id="run8">Run #8</button>
380 </div>
381 <hr/>
382
383 <h2>Query 9-A - Grouping and Aggregation</h2>
384 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700385 <div class="pretty-printed"><pre>
386 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700387
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700388 for $t in dataset TweetMessages
389 group by $uid := $t.user.screen-name with $t
390 return {
391 "user": $uid,
392 "count": count($t)
393 };
394 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700395
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700396 <div class="how-to-run"><pre><code class="javascript">
397 var expression9a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700398 .ForClause("$t", new AExpression("dataset TweetMessages"))
399 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700400 .ReturnClause(
401 {
402 "user" : "$uid",
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700403 "count" : new FunctionExpression("count", new AExpression("$t"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700404 }
405 );
406 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700407
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700408 <div class="result-output" id="result9a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700409 </div>
410
411 <button id="run9a">Run #9-A</button>
412 </div>
413 <hr/>
414
415 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
416 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700417 <div class="pretty-printed"><pre>
418 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700419
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700420 for $t in dataset TweetMessages
421 /*+ hash*/
422 group by $uid := $t.user.screen-name with $t
423 return {
424 "user": $uid,
425 "count": count($t)
426 };
427 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700428
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700429 <div class="how-to-run"><pre><code class="javascript">
430 var expression9b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700431 .ForClause("$t", new AExpression("dataset TweetMessages"))
432 .AQLClause("/*+ hash*/")
433 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700434 .ReturnClause(
435 {
436 "user" : "$uid",
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700437 "count" : new FunctionExpression("count", new AExpression("$t"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700438 }
439 );
440 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700441
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700442 <div class="result-output" id="result9b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700443 </div>
444
445 <button id="run9b">Run #9-B</button>
446 </div>
447 <hr/>
448
449 <h2>Query 10 - Grouping and Limits</h2>
450 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700451 <div class="pretty-printed"><pre>
452 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700453
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700454 for $t in dataset TweetMessages
455 group by $uid := $t.user.screen-name with $t
456 let $c := count($t)
457 order by $c desc
458 limit 3
459 return {
460 "user": $uid,
461 "count": $c
462 };
463 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700464
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700465 <div class="how-to-run"><pre><code class="javascript">
466 var expression10 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700467 .ForClause("$t", new AExpression("dataset TweetMessages"))
468 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
469 .LetClause("$c", new FunctionExpression("count", new AExpression("$t")))
470 .OrderbyClause( new AExpression("$c"), "desc" )
471 .LimitClause(new AExpression("3"))
472 .ReturnClause(
473 {
474 "user" : "$uid",
475 "count" : "$c"
476 }
477 );
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700478 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700479
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700480 <div class="result-output" id="result10">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700481 </div>
482
483 <button id="run10">Run #10</button>
484 </div>
485 <hr/>
486
487 <h2>Query 11 - Left Outer Fuzzy Join</h2>
488 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700489 <div class="pretty-printed"><pre>
490 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700491
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700492 set simfunction "jaccard";
493 set simthreshold "0.3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700494
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700495 for $t in dataset TweetMessages
496 return {
497 "tweet": $t,
498 "similar-tweets": for $t2 in dataset TweetMessages
499 where $t2.referred-topics ~= $t.referred-topics
500 and $t2.tweetid != $t.tweetid
501 return $t2.referred-topics
502 };
503 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700504
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700505 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700506 var expression11 = new FLWOGRExpression()
507 .ForClause( "$t", new AExpression("dataset TweetMessages"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700508 .ReturnClause({
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700509 "tweet" : new AExpression("$t"),
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700510 "similar-tweets": new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700511 .ForClause( "$t2", new AExpression("dataset TweetMessages"))
512 .WhereClause().and(
513 new AExpression("$t2.referred-topics ~= $t.referred-topics"),
514 new AExpression("$t2.tweetid != $t.tweetid")
515 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700516 .ReturnClause("$t2.referred-topics")
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700517 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700518 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700519
520 <div class="result-output" id="result11">
521 </div>
522
523 <button id="run11">Run #11</button>
524 </div>
525
526</body>
527</html>