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