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