| |
| |
| <!DOCTYPE html> |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Query operators & data types — Apache Usergrid 2.x documentation</title> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| |
| |
| |
| |
| |
| <link rel="top" title="Apache Usergrid 2.x documentation" href="../index.html"/> |
| <link rel="next" title="Advanced query usage" href="advanced-query-usage.html"/> |
| <link rel="prev" title="Query parameters & clauses" href="query-parameters.html"/> |
| |
| |
| <script src="../_static/js/modernizr.min.js"></script> |
| |
| </head> |
| |
| <body class="wy-body-for-nav" role="document"> |
| |
| <div class="wy-grid-for-nav"> |
| |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-nav-search"> |
| |
| |
| |
| <a href="../index.html" class="icon icon-home"> Apache Usergrid |
| |
| |
| |
| </a> |
| |
| |
| |
| |
| <div class="version"> |
| 2.x |
| </div> |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| <p class="caption"><span class="caption-text">Getting Started</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/overview.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/usergrid-features.html">Usergrid Features</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/data-model.html">Usergrid Data model</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/async-vs-sync.html">Async vs. sync calls</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Using Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-account.html">Creating a Usergrid Account</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-a-new-application.html">Creating a new application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-a-sandbox-app.html">Using a Sandbox Application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-the-api.html">Using the API</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Data Storage</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/data-store-dbms.html">The Usergrid Data Store</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/optimizing-access.html">Data Store Best Practices</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/collections.html">Collections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/entities.html">Entities</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Data Queries</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="querying-your-data.html">Querying your data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="query-parameters.html">Query parameters & clauses</a></li> |
| <li class="toctree-l1 current"><a class="current reference internal" href="">Query operators & data types</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="#operators">Operators</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#precedence">Precedence</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#data-types">Data types</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="advanced-query-usage.html">Advanced query usage</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Entity Connections</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/connecting-entities.html">Connecting entities</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/retrieving-entities.html">Retrieving connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/disconnecting-entities.html">Disconnecting entities</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Push Notifications</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/overview.html">Push notifications overview</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/adding-push-support.html">Adding push notifications support</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/getting-started.html">Getting started with push notifications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/tutorial.html">Tutorial: Push notifications sample app</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/registering.html">Registering with a notification service</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-notifiers.html">Creating notifiers</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/managing-users-and-devices.html">Managing users and devices</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-and-managing-notifications.html">Creating and managing notifications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/troubleshooting.html">Troubleshooting</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Security & Authentication</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/app-security.html">Security & token authentication</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-permissions.html">Using permissions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-roles.html">Using roles</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating users & app clients</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/user-authentication-types.html">Authentication levels</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/changing-token-time-live-ttl.html">Changing token expiration (time-to-live)</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-api-requests.html">Authenticating API requests</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/revoking-tokens-logout.html">Revoking tokens (logout)</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/facebook-sign.html">Facebook sign in</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/securing-your-app.html">Security best practices</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">User Management & Social Graph</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-management.html">User management & social graph</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/working-user-data.html">Working with User Data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/group.html">Working with group data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/activity.html">Activity</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-connections.html">Social Graph Connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-connections.html#creating-other-connections">Creating other connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/messagee-example.html">App Example - Messagee</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Geo-location</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../geolocation/geolocation.html">Geolocating your Entities</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Assets & Files</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/uploading-assets.html">Uploading assets</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/retrieving-assets.html">Retrieving assets</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/folders.html">Folders</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Counters & Events</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/events-and-counters.html">Counters & events</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html">Creating & incrementing counters</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#decrementing-resetting-counters">Decrementing/resetting counters</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#using-counters-hierarchically">Using counters hierarchically</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/retrieving-counters.html">Retrieving counters</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Organizations & Applications</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/managing.html">Organization & application management</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/organization.html">Organization</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/application.html">Application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/admin-user.html">Admin user</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">API Reference</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html">Methods</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#models">Models</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#sub-types">Sub-Types</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Client SDKs</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../sdks/tbd.html">COMING SOON...</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Installing Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../installation/deployment-guide.html">Usergrid 2.1.0 Deployment Guide</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">More about Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/presos-and-videos.html">Presentations & Videos</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/contribute-code.html">How to Contribute Code & Docs</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">Apache Usergrid</a> |
| </nav> |
| |
| |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| <ul class="wy-breadcrumbs"> |
| <li><a href="../index.html">Docs</a> »</li> |
| |
| <li>Query operators & data types</li> |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/data-queries/operators-and-types.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| </ul> |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="query-operators-data-types"> |
| <h1>Query operators & data types<a class="headerlink" href="#query-operators-data-types" title="Permalink to this headline">¶</a></h1> |
| <p>The following operators and data types are supported by the SQL-like |
| query language in Usergrid.</p> |
| <div class="section" id="operators"> |
| <h2>Operators<a class="headerlink" href="#operators" title="Permalink to this headline">¶</a></h2> |
| <table class="usergrid-table"> |
| <tr> |
| <td><p>Operator</p> |
| </td> |
| <td><p>Purpose</p> |
| </td> |
| <td><p>Example</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>‘<’ or ‘lt’</p> |
| </td> |
| <td><p>Less than</p> |
| </td> |
| <td><p>select * where quantity > ‘1000’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>‘<=’ or ‘lte’</p> |
| </td> |
| <td><p>Less than or equal to</p> |
| </td> |
| <td><p>Example</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>‘=’ or ‘eq’</p> |
| </td> |
| <td><p>Equals</p> |
| </td> |
| <td><p>select * where price = ‘20.00’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>‘>=’ or ‘gte’</p> |
| </td> |
| <td><p>Greater than or equal to</p> |
| </td> |
| <td><p>select * where quantity >= ‘1000’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>‘>’ or ‘gt’</p> |
| </td> |
| <td><p>Greater than</p> |
| </td> |
| <td><p>select * where quantity > ‘1000’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>not</p> |
| </td> |
| <td><p>Subtraction of results</p> |
| </td> |
| <td><p>select * where quantity < ‘4000’ and not quantity = ‘2000’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>contains</p> |
| </td> |
| <td><p>Narrow by contained text</p> |
| </td> |
| <td><p>select * where title contains ‘tale’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>and</p> |
| </td> |
| <td><p>Union of results</p> |
| </td> |
| <td><p>select * where quantity > ‘1000’ and quantity < ‘4000’</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>or</p> |
| </td> |
| <td><p>Intersection of results</p> |
| </td> |
| <td><p>select * where quantity = ‘1000’ or quantity = ‘4000’</p> |
| </td> |
| </tr> |
| </table><div class="section" id="precedence"> |
| <h3>Precedence<a class="headerlink" href="#precedence" title="Permalink to this headline">¶</a></h3> |
| <p>The operators at the bottom of the above table are the ones with lower |
| precedence. When a query is evaluated the comparison operators (=, > , |
| <, <= and >=) will be evaluated first. And next “not”, “contains” and |
| “or” will be evaluated and in that order.</p> |
| <p>Though they are not shown above, parentheses are allowed and may be used |
| to group query expressions.</p> |
| <p>For example, given our rules of precedence, these two queries are |
| equivalent:</p> |
| <div class="highlight-python"><div class="highlight"><pre>select * where age > 6 or size = 'large' and color = 'tabby' |
| |
| select * where (age > 6 or size = 'large') and color = 'tabby' |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| <div class="section" id="data-types"> |
| <h2>Data types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h2> |
| <p>As you develop queries, remember that entity properties each conform to |
| a particular data type. For example, in the default entity User, the |
| name property is stored as a string, the created date as a long, and |
| metadata is stored as a JSON object. Your queries must be data |
| type-aware to ensure that query results are as you expect them to be.</p> |
| <p>For example, if you create an entity with a price property with a value |
| of 100.00, querying for 100 will return no results, since the API |
| expected a decimal-delimited float value in your query.</p> |
| <p>For a list of property data types for each default entities, see |
| <a class="reference external" href="../rest-endpoints/api-doc.html#models">Default Data Entities</a>s.</p> |
| <table class="usergrid-table"> |
| <tr> |
| <td><p>string</p> |
| </td> |
| <td><pre>'value', unicode '\uFFFF', octal '\0707'</pre></td> |
| </tr> |
| <tr> |
| <td><p>long</p> |
| </td> |
| <td><pre>1357412326021</pre> |
| |
| Timestamps are typically stored as long values.</td> |
| </tr> |
| <tr> |
| <td><p>float</p> |
| </td> |
| <td><pre>10.1, -10.1, 10e10, 10e-10, 10E10, 10E-10</pre> |
| |
| Your query must be specific about the value you're looking for, down to<p>the value (if any) after the decimal point.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><p>boolean</p> |
| </td> |
| <td><pre>true | false</pre></td> |
| </tr> |
| <tr> |
| <td><p>UUID</p> |
| </td> |
| <td><pre>ee912c4b-5769-11e2-924d-02e81ac5a17b</pre></td> |
| </tr> |
| <tr> |
| <td><p>Array</p> |
| </td> |
| <td><pre>["boat", "car", "bike"]</pre></td> |
| </tr> |
| <tr> |
| <td><p>object</p> |
| </td> |
| <td><p><p>For a JSON object like this one:</p> |
| </p> |
| <pre> |
| { |
| "items": [ |
| { |
| "name": "rocks" |
| }, |
| { |
| "name": "boats" |
| } |
| ] |
| } |
| </pre> |
| <p><p>you can use dot notation to reach property values in the object:</p> |
| </p> |
| <pre> |
| /mycollection/thing?ql="select * where items.name = 'rocks'" |
| </pre> |
| <p><p>Objects are often used to contain entity metadata, such as the |
| activities associated with a user, the users associated with a role, and |
| so on.</p> |
| </p> |
| <p><p>Please note that object properties are not indexed. This means queries |
| using dot-notation will be much slower than queries on indexed entity |
| properties.</p> |
| </p></td> |
| </tr> |
| </table></div> |
| </div> |
| |
| |
| </div> |
| </div> |
| <footer> |
| |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| |
| <a href="advanced-query-usage.html" class="btn btn-neutral float-right" title="Advanced query usage" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="query-parameters.html" class="btn btn-neutral" title="Query parameters & clauses" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| |
| </div> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2013-2015, Apache Usergrid. |
| |
| </p> |
| </div> |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'../', |
| VERSION:'2.x', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true |
| }; |
| </script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.StickyNav.enable(); |
| }); |
| </script> |
| |
| |
| </body> |
| </html> |