Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > e450e7f3d6075c4a54de19e68d38177f > files > 300

groonga-doc-3.0.5-1.fc18.x86_64.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>8.10.1. Query syntax &mdash; groonga v3.0.5 documentation</title>
    
    <link rel="stylesheet" href="../../_static/groonga.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '3.0.5',
        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>
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
    <link rel="top" title="groonga v3.0.5 documentation" href="../../index.html" />
    <link rel="up" title="8.10. grn_expr" href="../grn_expr.html" />
    <link rel="next" title="8.10.2. Script syntax" href="script_syntax.html" />
    <link rel="prev" title="8.10. grn_expr" href="../grn_expr.html" /> 
  </head>
  <body>
<div class="header">
  <h1 class="title">
    <a id="top-link" href="../../index.html">
      <span class="project">groonga</span>
      <span class="separator">-</span>
      <span class="description">An open-source fulltext search engine and column store.</span>
    </a>
  </h1>

  <div class="other-language-links">
    <ul>
      <li><a href="../../../../ja/html/reference/grn_expr/query_syntax.html"><img src="../../_static/jp.png" alt="日本語">日本語版はこちら</a></li>
    </ul>
  </div>
</div>
  

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="script_syntax.html" title="8.10.2. Script syntax"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../grn_expr.html" title="8.10. grn_expr"
             accesskey="P">previous</a> |</li>
        <li><a href="../../index.html">groonga v3.0.5 documentation</a> &raquo;</li>
          <li><a href="../../reference.html" >8. リファレンスマニュアル</a> &raquo;</li>
          <li><a href="../grn_expr.html" accesskey="U">8.10. grn_expr</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="query-syntax">
<h1>8.10.1. Query syntax<a class="headerlink" href="#query-syntax" title="Permalink to this headline">¶</a></h1>
<p>Query syntax is a syntax to specify search condition for common Web
search form. It is similar to the syntax of Google's search form. For
example, <tt class="docutils literal"><span class="pre">word1</span> <span class="pre">word2</span></tt> means that groonga searches records that
contain both <tt class="docutils literal"><span class="pre">word1</span></tt> and <tt class="docutils literal"><span class="pre">word2</span></tt>. <tt class="docutils literal"><span class="pre">word1</span> <span class="pre">OR</span> <span class="pre">word2</span></tt> means that
groogna searches records that contain either <tt class="docutils literal"><span class="pre">word1</span></tt> or <tt class="docutils literal"><span class="pre">word2</span></tt>.</p>
<p>Query syntax consists of <tt class="docutils literal"><span class="pre">conditional</span> <span class="pre">expression</span></tt>, <tt class="docutils literal"><span class="pre">combind</span>
<span class="pre">expression</span></tt> and <tt class="docutils literal"><span class="pre">assignment</span> <span class="pre">expression</span></tt>. Nomrally <tt class="docutils literal"><span class="pre">assignment</span>
<span class="pre">expression</span></tt> can be ignored. Because <tt class="docutils literal"><span class="pre">assignment</span> <span class="pre">expression</span></tt> is
disabled in <tt class="docutils literal"><span class="pre">--query</span></tt> option of <a class="reference internal" href="../commands/select.html"><em>select</em></a>. You can use
it if you use groonga as library and customize query syntax parser
options.</p>
<p><tt class="docutils literal"><span class="pre">Conditinal</span> <span class="pre">expression</span></tt> specifies an condition. <tt class="docutils literal"><span class="pre">Combinded</span>
<span class="pre">expression</span></tt> consists of one or more <tt class="docutils literal"><span class="pre">conditional</span> <span class="pre">expression</span></tt>,
<tt class="docutils literal"><span class="pre">combined</span> <span class="pre">expression</span></tt> or <tt class="docutils literal"><span class="pre">assignment</span> <span class="pre">expression</span></tt>. <tt class="docutils literal"><span class="pre">Assignment</span>
<span class="pre">expression</span></tt> can assigns a column to a value.</p>
<div class="section" id="sample-data">
<h2>8.10.1.1. Sample data<a class="headerlink" href="#sample-data" title="Permalink to this headline">¶</a></h2>
<p>Here are a schema definition and sample data to show usage.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create Entries TABLE_PAT_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries n_likes COLUMN_SCALAR UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_key_index COLUMN_INDEX|WITH_POSITION Entries _key
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_content_index COLUMN_INDEX|WITH_POSITION Entries content
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Entries
[
{&quot;_key&quot;:    &quot;The first post!&quot;,
 &quot;content&quot;: &quot;Welcome! This is my first post!&quot;,
 &quot;n_likes&quot;: 5},
{&quot;_key&quot;:    &quot;Groonga&quot;,
 &quot;content&quot;: &quot;I started to use groonga. It&#39;s very fast!&quot;,
 &quot;n_likes&quot;: 10},
{&quot;_key&quot;:    &quot;Mroonga&quot;,
 &quot;content&quot;: &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
 &quot;n_likes&quot;: 15},
{&quot;_key&quot;:    &quot;Good-bye Senna&quot;,
 &quot;content&quot;: &quot;I migrated all Senna system!&quot;,
 &quot;n_likes&quot;: 3},
{&quot;_key&quot;:    &quot;Good-bye Tritonn&quot;,
 &quot;content&quot;: &quot;I also migrated all Tritonn system!&quot;,
 &quot;n_likes&quot;: 3}
]
# [[0, 1337566253.89858, 0.000355720520019531], 5]
</pre></div>
</div>
<p>There is a table, <tt class="docutils literal"><span class="pre">Entries</span></tt>, for blog entries. An entry has title,
content and the number of likes for the entry. Title is key of
<tt class="docutils literal"><span class="pre">Entries</span></tt>. Content is value of <tt class="docutils literal"><span class="pre">Entries.content</span></tt> column. The
number of likes is value of <tt class="docutils literal"><span class="pre">Entries.n_likes</span></tt> column.</p>
<p><tt class="docutils literal"><span class="pre">Entries._key</span></tt> column and <tt class="docutils literal"><span class="pre">Entries.content</span></tt> column are indexed
using <tt class="docutils literal"><span class="pre">TokenBigram</span></tt> tokenizer. So both <tt class="docutils literal"><span class="pre">Entries._key</span></tt> and
<tt class="docutils literal"><span class="pre">Entries.content</span></tt> are fulltext search ready.</p>
<p>OK. The schema and data for examples are ready.</p>
</div>
<div class="section" id="escape">
<h2>8.10.1.2. Escape<a class="headerlink" href="#escape" title="Permalink to this headline">¶</a></h2>
<p>There are special characters in query syntax. To use a special
character as itself, it should be escaped by prepending <tt class="docutils literal"><span class="pre">\</span></tt>. For
example, <tt class="docutils literal"><span class="pre">&quot;</span></tt> is a special character. It is escaped as <tt class="docutils literal"><span class="pre">\&quot;</span></tt>.</p>
<p>Here is a special character list:</p>
<blockquote>
<div><ul class="simple">
<li><tt class="docutils literal"><span class="pre">[space]</span></tt> (escaped as <tt class="docutils literal"><span class="pre">[backquote][space]</span></tt>) (You should
substitute <tt class="docutils literal"><span class="pre">[space]</span></tt> with a white space character that is 0x20
in ASCII and <tt class="docutils literal"><span class="pre">[backquote]</span></tt> with <tt class="docutils literal"><span class="pre">\\</span></tt>.)</li>
<li><tt class="docutils literal"><span class="pre">&quot;</span></tt> (escaped as <tt class="docutils literal"><span class="pre">\&quot;</span></tt>)</li>
<li><tt class="docutils literal"><span class="pre">'</span></tt> (escaped as <tt class="docutils literal"><span class="pre">\'</span></tt>)</li>
<li><tt class="docutils literal"><span class="pre">(</span></tt> (escaped as <tt class="docutils literal"><span class="pre">\(</span></tt>)</li>
<li><tt class="docutils literal"><span class="pre">)</span></tt> (escaped as <tt class="docutils literal"><span class="pre">\)</span></tt>)</li>
<li><tt class="docutils literal"><span class="pre">\</span></tt> (escaped as <tt class="docutils literal"><span class="pre">\\</span></tt>)</li>
</ul>
</div></blockquote>
<p>You can use quote instead of escape. Quote syntax is <tt class="docutils literal"><span class="pre">&quot;...&quot;</span></tt> or
<tt class="docutils literal"><span class="pre">'...'</span></tt>. You need escape <tt class="docutils literal"><span class="pre">&quot;</span></tt> as <tt class="docutils literal"><span class="pre">\&quot;</span></tt> in <tt class="docutils literal"><span class="pre">&quot;...&quot;</span></tt> quote syntax.
You need escape <tt class="docutils literal"><span class="pre">'</span></tt> as <tt class="docutils literal"><span class="pre">\'</span></tt> in <tt class="docutils literal"><span class="pre">'...'</span></tt> quote syntax. For
example, <tt class="docutils literal"><span class="pre">Alice's</span> <span class="pre">brother</span> <span class="pre">(Bob)</span></tt> can be quoted <tt class="docutils literal"><span class="pre">&quot;Alice's</span> <span class="pre">brother</span>
<span class="pre">(Bob)&quot;</span></tt> or <tt class="docutils literal"><span class="pre">'Alice\'s</span> <span class="pre">brother</span> <span class="pre">(Bob)'</span></tt>.</p>
</div>
<div class="section" id="conditional-expression">
<span id="id1"></span><h2>8.10.1.3. Conditional expression<a class="headerlink" href="#conditional-expression" title="Permalink to this headline">¶</a></h2>
<p>Here is available conditional expression list.</p>
<div class="section" id="full-text-search-condition">
<span id="id2"></span><h3>8.10.1.3.1. Full text search condition<a class="headerlink" href="#full-text-search-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">keyword</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">Full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span></tt> specifies a full text search condition
against the default match columns. Match columns are full text search
target columns.</p>
<p>You should specify the default match columns for full text
search. They can be specified by <tt class="docutils literal"><span class="pre">--match_columns</span></tt> option of
<a class="reference internal" href="../commands/select.html"><em>select</em></a>. If you don't specify the default match
columns, this conditional expression fails.</p>
<p>This conditional expression does full text search with
<tt class="docutils literal"><span class="pre">keyword</span></tt>. <tt class="docutils literal"><span class="pre">keyword</span></tt> should not contain any spaces. If <tt class="docutils literal"><span class="pre">keyword</span></tt>
contains a space such as <tt class="docutils literal"><span class="pre">search</span> <span class="pre">keyword</span></tt>, it means two full text
search conditions; <tt class="docutils literal"><span class="pre">search</span></tt> and <tt class="docutils literal"><span class="pre">keyword</span></tt>. If you want to
specifies a keyword that contains one or more spaces, you can use
<tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt> that is described below.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --match_columns content --query fast
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that contain a word <tt class="docutils literal"><span class="pre">fast</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value.</p>
<p><tt class="docutils literal"><span class="pre">content</span></tt> column is the default match column.</p>
</div>
<div class="section" id="phrase-search-condition">
<span id="id3"></span><h3>8.10.1.3.2. Phrase search condition<a class="headerlink" href="#phrase-search-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">&quot;search</span> <span class="pre">keyword&quot;</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">Phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt> specifies a phrase search condition
against the default match columns.</p>
<p>You should specify the default match columns for full text
search. They can be specified by <tt class="docutils literal"><span class="pre">--match_columns</span></tt> option of
<a class="reference internal" href="../commands/select.html"><em>select</em></a>. If you don't specify the default match
columns, this conditional expression fails.</p>
<p>This conditional expression does phrase search with <tt class="docutils literal"><span class="pre">search</span>
<span class="pre">keyword</span></tt>. Phrase search searches records that contain <tt class="docutils literal"><span class="pre">search</span></tt> and
<tt class="docutils literal"><span class="pre">keyword</span></tt> and those terms are appeared in the same order and
adjacent. Thus, <tt class="docutils literal"><span class="pre">Put</span> <span class="pre">a</span> <span class="pre">search</span> <span class="pre">keyword</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">form</span></tt> is matched but
<tt class="docutils literal"><span class="pre">Search</span> <span class="pre">by</span> <span class="pre">the</span> <span class="pre">keyword</span></tt> and <tt class="docutils literal"><span class="pre">There</span> <span class="pre">is</span> <span class="pre">a</span> <span class="pre">keyword.</span> <span class="pre">Search</span> <span class="pre">by</span> <span class="pre">it!</span></tt>
aren't matched.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --match_columns content --query &#39;&quot;I started&quot;&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that contain a phrase <tt class="docutils literal"><span class="pre">I</span> <span class="pre">started</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value. <tt class="docutils literal"><span class="pre">I</span> <span class="pre">also</span> <span class="pre">started</span></tt> isn't matched because
<tt class="docutils literal"><span class="pre">I</span></tt> and <tt class="docutils literal"><span class="pre">started</span></tt> aren't adjacent.</p>
<p><tt class="docutils literal"><span class="pre">content</span></tt> column is the default match column.</p>
</div>
<div class="section" id="full-text-search-condition-with-explicit-match-column">
<h3>8.10.1.3.3. Full text search condition (with explicit match column)<a class="headerlink" href="#full-text-search-condition-with-explicit-match-column" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&#64;keyword</span></tt>.</p>
<p>It's similar to <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span></tt> but it doesn't require
the default match columns. You need to specify match column for the
full text search condition by <tt class="docutils literal"><span class="pre">column:</span></tt> instead of
<tt class="docutils literal"><span class="pre">--match_columns</span></tt> option of <a class="reference internal" href="../commands/select.html"><em>select</em></a>.</p>
<p>This condtional expression is useful when you want to use two or more
full text search against different columns. The default match columns
specified by <tt class="docutils literal"><span class="pre">--match_columns</span></tt> option can't be specified multiple
times. You need to specify the second match column by this conditional
expression.</p>
<p>The different between <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span> <span class="pre">(with</span> <span class="pre">explicit</span> <span class="pre">match</span> <span class="pre">column)</span></tt> is whether advanced
match columns are supported or not. <tt class="docutils literal"><span class="pre">Full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span></tt>
supports advanced match columns but <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span> <span class="pre">(with</span>
<span class="pre">explicit</span> <span class="pre">match</span> <span class="pre">column)</span></tt> isn't supported. Advanced match columns has
the following features:</p>
<blockquote>
<div><ul class="simple">
<li>Weight is supported.</li>
<li>Using multiple columns are supported.</li>
<li>Using index column as a match column is supported.</li>
</ul>
</div></blockquote>
<p>See description of <tt class="docutils literal"><span class="pre">--match_columns</span></tt> option of
<a class="reference internal" href="../commands/select.html"><em>select</em></a> about them.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query content:@fast
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that contain a word <tt class="docutils literal"><span class="pre">fast</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value.</p>
</div>
<div class="section" id="phrase-search-condition-with-explicit-match-column">
<h3>8.10.1.3.4. Phrase search condition (with explicit match column)<a class="headerlink" href="#phrase-search-condition-with-explicit-match-column" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&#64;&quot;search</span> <span class="pre">keyword&quot;</span></tt>.</p>
<p>It's similar to <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt> but it doesn't require the
default match columns. You need to specify match column for the phrase
search condition by <tt class="docutils literal"><span class="pre">column:</span></tt> instead of <tt class="docutils literal"><span class="pre">--match_columns</span></tt> option
of <a class="reference internal" href="../commands/select.html"><em>select</em></a>.</p>
<p>The different between <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span>
<span class="pre">condition</span> <span class="pre">(with</span> <span class="pre">explicit</span> <span class="pre">match</span> <span class="pre">column)</span></tt> is similar to between <tt class="docutils literal"><span class="pre">full</span>
<span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span> <span class="pre">search</span> <span class="pre">condition</span> <span class="pre">(with</span>
<span class="pre">explicit</span> <span class="pre">match</span> <span class="pre">column)</span></tt>. <tt class="docutils literal"><span class="pre">Phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt> supports
advanced match columns but <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span> <span class="pre">(with</span> <span class="pre">explicit</span>
<span class="pre">match</span> <span class="pre">column)</span></tt> isn't supported. See description of <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span> <span class="pre">search</span>
<span class="pre">condition</span> <span class="pre">(with</span> <span class="pre">explicit</span> <span class="pre">match</span> <span class="pre">column)</span></tt> about advanced match columns.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;content:@&quot;I started&quot;&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that contain a phrase <tt class="docutils literal"><span class="pre">I</span> <span class="pre">started</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value. <tt class="docutils literal"><span class="pre">I</span> <span class="pre">also</span> <span class="pre">started</span></tt> isn't matched because
<tt class="docutils literal"><span class="pre">I</span></tt> and <tt class="docutils literal"><span class="pre">started</span></tt> aren't adjacent.</p>
</div>
<div class="section" id="prefix-search-condition">
<span id="id4"></span><h3>8.10.1.3.5. Prefix search condition<a class="headerlink" href="#prefix-search-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:^value</span></tt> or <tt class="docutils literal"><span class="pre">value*</span></tt>.</p>
<p>This conditional expression does prefix search with <tt class="docutils literal"><span class="pre">value</span></tt>. Prefix
search searches records that contain a word that starts with <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>You can use fast prefix search against a column. The column must be
indexed and index table must be patricia trie table
(<tt class="docutils literal"><span class="pre">TABLE_PAT_KEY</span></tt>) or double array trie table
(<tt class="docutils literal"><span class="pre">TABLE_DAT_KEY</span></tt>). You can also use fast prefix search against
<tt class="docutils literal"><span class="pre">_key</span></tt> pseudo column of patricia trie table or double array trie
table. You don't need to index <tt class="docutils literal"><span class="pre">_key</span></tt>.</p>
<p>Prefix search can be used with other table types but it causes all
records scan. It's not problem for small records but it spends more
time for large records.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;_key:^Goo&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         5,
#         &quot;Good-bye Tritonn&quot;,
#         &quot;I also migrated all Tritonn system!&quot;,
#         3
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that contain a word that starts with
<tt class="docutils literal"><span class="pre">Goo</span></tt> in <tt class="docutils literal"><span class="pre">_key</span></tt> pseudo column value. <tt class="docutils literal"><span class="pre">Good-bye</span> <span class="pre">Senna</span></tt> and
<tt class="docutils literal"><span class="pre">Good-bye</span> <span class="pre">Tritonn</span></tt> are matched with the expression.</p>
</div>
<div class="section" id="suffix-search-condition">
<span id="id5"></span><h3>8.10.1.3.6. Suffix search condition<a class="headerlink" href="#suffix-search-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:$value</span></tt>.</p>
<p>This conditional expression does suffix search with <tt class="docutils literal"><span class="pre">value</span></tt>. Suffix
search searches records that contain a word that ends with <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>You can use fast suffix search against a column. The column must be
indexed and index table must be patricia trie table
(<tt class="docutils literal"><span class="pre">TABLE_PAT_KEY</span></tt>) with <tt class="docutils literal"><span class="pre">KEY_WITH_SIS</span></tt> flag. You can also use fast
suffix search against <tt class="docutils literal"><span class="pre">_key</span></tt> pseudo column of patricia trie table
(<tt class="docutils literal"><span class="pre">TABLE_PAT_KEY</span></tt>) with <tt class="docutils literal"><span class="pre">KEY_WITH_SIS</span></tt> flag. You don't need to
index <tt class="docutils literal"><span class="pre">_key</span></tt>. We recommended that you use index column based fast
suffix search instead of <tt class="docutils literal"><span class="pre">_key</span></tt> based fast suffix search. <tt class="docutils literal"><span class="pre">_key</span></tt>
based fast suffix search returns automatically registered
substrings. (TODO: write document about suffix search and link to it
from here.)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Fast suffix search can be used only for non-ASCII characters such
as hiragana in Japanese. You cannot use fast suffix search for
ASCII character.</p>
</div>
<p>Suffix search can be used with other table types or patricia trie
table without <tt class="docutils literal"><span class="pre">KEY_WITH_SIS</span></tt> flag but it causes all records
scan. It's not problem for small records but it spends more time for
large records.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple. It uses fast suffix search for hiragana in
Japanese that is one of non-ASCII characters.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create Titles TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Titles content COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create SuffixSearchTerms TABLE_PAT_KEY|KEY_WITH_SIS ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create SuffixSearchTerms index COLUMN_INDEX Titles content
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Titles
[
{&quot;content&quot;: &quot;ぐるんが&quot;},
{&quot;content&quot;: &quot;むるんが&quot;},
{&quot;content&quot;: &quot;せな&quot;},
{&quot;content&quot;: &quot;とりとん&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 4]
select Titles --query &#39;content:$んが&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;むるんが&quot;
#       ],
#       [
#         1,
#         &quot;ぐるんが&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that have value that ends with <tt class="docutils literal"><span class="pre">んが</span></tt>
in <tt class="docutils literal"><span class="pre">content</span></tt> column value. <tt class="docutils literal"><span class="pre">ぐるんが</span></tt> and <tt class="docutils literal"><span class="pre">むるんが</span></tt> are matched
with the expression.</p>
</div>
<div class="section" id="equal-condition">
<h3>8.10.1.3.7. Equal condition<a class="headerlink" href="#equal-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value is equal to <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query _key:Groonga
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">_key</span></tt> column value is
equal to <tt class="docutils literal"><span class="pre">Groonga</span></tt>.</p>
</div>
<div class="section" id="not-equal-condition">
<h3>8.10.1.3.8. Not equal condition<a class="headerlink" href="#not-equal-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:!value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value isn't equal to <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query _key:!Groonga
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         4
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ],
#       [
#         5,
#         &quot;Good-bye Tritonn&quot;,
#         &quot;I also migrated all Tritonn system!&quot;,
#         3
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ],
#       [
#         1,
#         &quot;The first post!&quot;,
#         &quot;Welcome! This is my first post!&quot;,
#         5
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">_key</span></tt> column value is not equal
to <tt class="docutils literal"><span class="pre">Groonga</span></tt>.</p>
</div>
<div class="section" id="less-than-condition">
<h3>8.10.1.3.9. Less than condition<a class="headerlink" href="#less-than-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&lt;value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value is less than <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>If <tt class="docutils literal"><span class="pre">column</span></tt> type is numerical type such as <tt class="docutils literal"><span class="pre">Int32</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt>
value and <tt class="docutils literal"><span class="pre">value</span></tt> are compared as number. If <tt class="docutils literal"><span class="pre">column</span></tt> type is text
type such as <tt class="docutils literal"><span class="pre">ShortText</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt> value and <tt class="docutils literal"><span class="pre">value</span></tt> are
compared as bit sequence.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query n_likes:&lt;10
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ],
#       [
#         5,
#         &quot;Good-bye Tritonn&quot;,
#         &quot;I also migrated all Tritonn system!&quot;,
#         3
#       ],
#       [
#         1,
#         &quot;The first post!&quot;,
#         &quot;Welcome! This is my first post!&quot;,
#         5
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is less
than <tt class="docutils literal"><span class="pre">10</span></tt>.</p>
</div>
<div class="section" id="greater-than-condition">
<h3>8.10.1.3.10. Greater than condition<a class="headerlink" href="#greater-than-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&gt;value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value is greater than <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>If <tt class="docutils literal"><span class="pre">column</span></tt> type is numerical type such as <tt class="docutils literal"><span class="pre">Int32</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt>
value and <tt class="docutils literal"><span class="pre">value</span></tt> are compared as number. If <tt class="docutils literal"><span class="pre">column</span></tt> type is text
type such as <tt class="docutils literal"><span class="pre">ShortText</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt> value and <tt class="docutils literal"><span class="pre">value</span></tt> are
compared as bit sequence.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query n_likes:&gt;10
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is greater
than <tt class="docutils literal"><span class="pre">10</span></tt>.</p>
</div>
<div class="section" id="less-than-or-equal-to-condition">
<h3>8.10.1.3.11. Less than or equal to condition<a class="headerlink" href="#less-than-or-equal-to-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&lt;=value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value is less than or equal to
<tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>If <tt class="docutils literal"><span class="pre">column</span></tt> type is numerical type such as <tt class="docutils literal"><span class="pre">Int32</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt>
value and <tt class="docutils literal"><span class="pre">value</span></tt> are compared as number. If <tt class="docutils literal"><span class="pre">column</span></tt> type is text
type such as <tt class="docutils literal"><span class="pre">ShortText</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt> value and <tt class="docutils literal"><span class="pre">value</span></tt> are
compared as bit sequence.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query n_likes:&lt;=10
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         4
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ],
#       [
#         5,
#         &quot;Good-bye Tritonn&quot;,
#         &quot;I also migrated all Tritonn system!&quot;,
#         3
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ],
#       [
#         1,
#         &quot;The first post!&quot;,
#         &quot;Welcome! This is my first post!&quot;,
#         5
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is less
than or equal to <tt class="docutils literal"><span class="pre">10</span></tt>.</p>
</div>
<div class="section" id="greater-than-or-equal-to-condition">
<h3>8.10.1.3.12. Greater than or equal to condition<a class="headerlink" href="#greater-than-or-equal-to-condition" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">column:&gt;=value</span></tt>.</p>
<p>It matches records that <tt class="docutils literal"><span class="pre">column</span></tt> value is greater than or equal to
<tt class="docutils literal"><span class="pre">value</span></tt>.</p>
<p>If <tt class="docutils literal"><span class="pre">column</span></tt> type is numerical type such as <tt class="docutils literal"><span class="pre">Int32</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt>
value and <tt class="docutils literal"><span class="pre">value</span></tt> are compared as number. If <tt class="docutils literal"><span class="pre">column</span></tt> type is text
type such as <tt class="docutils literal"><span class="pre">ShortText</span></tt>, <tt class="docutils literal"><span class="pre">column</span></tt> value and <tt class="docutils literal"><span class="pre">value</span></tt> are
compared as bit sequence.</p>
<p>It doesn't require the default match columns such as <tt class="docutils literal"><span class="pre">full</span> <span class="pre">text</span>
<span class="pre">search</span> <span class="pre">condition</span></tt> and <tt class="docutils literal"><span class="pre">phrase</span> <span class="pre">search</span> <span class="pre">condition</span></tt>.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query n_likes:&gt;=10
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is
greater than or equal to <tt class="docutils literal"><span class="pre">10</span></tt>.</p>
</div>
</div>
<div class="section" id="combined-expression">
<span id="id6"></span><h2>8.10.1.4. Combined expression<a class="headerlink" href="#combined-expression" title="Permalink to this headline">¶</a></h2>
<p>Here is available combined expression list.</p>
<div class="section" id="logical-or">
<h3>8.10.1.4.1. Logical OR<a class="headerlink" href="#logical-or" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">a</span> <span class="pre">OR</span> <span class="pre">b</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt> are conditional expressions, conbinded expressions or
assignment expressions.</p>
<p>If at least one of <tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt> are matched, <tt class="docutils literal"><span class="pre">a</span> <span class="pre">OR</span> <span class="pre">b</span></tt> is matched.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;n_likes:&gt;10 OR content:@senna&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is
greater than <tt class="docutils literal"><span class="pre">10</span></tt> or contain a word <tt class="docutils literal"><span class="pre">senna</span></tt> in <tt class="docutils literal"><span class="pre">content</span></tt> column
value.</p>
</div>
<div class="section" id="logical-and">
<h3>8.10.1.4.2. Logical AND<a class="headerlink" href="#logical-and" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></tt> or just <tt class="docutils literal"><span class="pre">a</span> <span class="pre">b</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt> are conditional expressions, conbinded expressions or
assignment expressions.</p>
<p>If both <tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt> are matched, <tt class="docutils literal"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></tt> is matched.</p>
<p>You can specify <tt class="docutils literal"><span class="pre">+</span></tt> the first expression such as <tt class="docutils literal"><span class="pre">+a</span></tt>. The <tt class="docutils literal"><span class="pre">+</span></tt>
is just ignored.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;n_likes:&gt;=10 + content:@groonga&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is
greater than or equal to <tt class="docutils literal"><span class="pre">10</span></tt> and contain a word <tt class="docutils literal"><span class="pre">groonga</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value.</p>
</div>
<div class="section" id="logical-not">
<h3>8.10.1.4.3. Logical NOT<a class="headerlink" href="#logical-not" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt> are conditional expressions, conbinded expressions or
assignment expressions.</p>
<p>If <tt class="docutils literal"><span class="pre">a</span></tt> is matched and <tt class="docutils literal"><span class="pre">b</span></tt> is not matched, <tt class="docutils literal"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></tt> is matched.</p>
<p>You can not specify <tt class="docutils literal"><span class="pre">-</span></tt> the first expression such as <tt class="docutils literal"><span class="pre">-a</span></tt>. It's
syntax error.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;n_likes:&gt;=10 - content:@groonga&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The expression matches records that <tt class="docutils literal"><span class="pre">n_likes</span></tt> column value is
greater than or equal to <tt class="docutils literal"><span class="pre">10</span></tt> and don't contain a word <tt class="docutils literal"><span class="pre">groonga</span></tt> in
<tt class="docutils literal"><span class="pre">content</span></tt> column value.</p>
</div>
<div class="section" id="grouping">
<h3>8.10.1.4.4. Grouping<a class="headerlink" href="#grouping" title="Permalink to this headline">¶</a></h3>
<p>Its syntax is <tt class="docutils literal"><span class="pre">(...)</span></tt>. <tt class="docutils literal"><span class="pre">...</span></tt> is space separated expression list.</p>
<p><tt class="docutils literal"><span class="pre">(...)</span></tt> groups one ore more expressions and they can be
processed as an expression. <tt class="docutils literal"><span class="pre">a</span> <span class="pre">b</span> <span class="pre">OR</span> <span class="pre">c</span></tt> means that <tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt>
are matched or <tt class="docutils literal"><span class="pre">c</span></tt> is matched. <tt class="docutils literal"><span class="pre">a</span> <span class="pre">(b</span> <span class="pre">OR</span> <span class="pre">c)</span></tt> means that <tt class="docutils literal"><span class="pre">a</span></tt> and
one of <tt class="docutils literal"><span class="pre">b</span></tt> and <tt class="docutils literal"><span class="pre">c</span></tt> are matched.</p>
<p>Here is a simple exmaple.</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>select Entries --query &#39;n_likes:&lt;5 content:@senna OR content:@fast&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ],
#       [
#         2,
#         &quot;Groonga&quot;,
#         &quot;I started to use groonga. It&#39;s very fast!&quot;,
#         10
#       ],
#       [
#         3,
#         &quot;Mroonga&quot;,
#         &quot;I also started to use mroonga. It&#39;s also very fast! Really fast!&quot;,
#         15
#       ]
#     ]
#   ]
# ]
select Entries --query &#39;n_likes:&lt;5 (content:@senna OR content:@fast)&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ],
#         [
#           &quot;n_likes&quot;,
#           &quot;UInt32&quot;
#         ]
#       ],
#       [
#         4,
#         &quot;Good-bye Senna&quot;,
#         &quot;I migrated all Senna system!&quot;,
#         3
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>The first expression doesn't use grouping. It matches records that
<tt class="docutils literal"><span class="pre">n_likes:&lt;5</span></tt> and <tt class="docutils literal"><span class="pre">content:&#64;senna</span></tt> are matched or
<tt class="docutils literal"><span class="pre">content:&#64;fast</span></tt> is matched.</p>
<p>The second expression uses grouping. It matches records that
<tt class="docutils literal"><span class="pre">n_likes:&lt;5</span></tt> and one of <tt class="docutils literal"><span class="pre">content:&#64;senna</span></tt> or <tt class="docutils literal"><span class="pre">content:&#64;fast</span></tt>
are matched.</p>
</div>
</div>
<div class="section" id="assignment-expression">
<h2>8.10.1.5. Assignment expression<a class="headerlink" href="#assignment-expression" title="Permalink to this headline">¶</a></h2>
<p>This section is for advanced users. Because assignment expression is
disabled in <tt class="docutils literal"><span class="pre">--query</span></tt> option of <a class="reference internal" href="../commands/select.html"><em>select</em></a> by
default. You need to specify <tt class="docutils literal"><span class="pre">ALLOW_COLUMN|ALLOW_UPDATE</span></tt> as
<tt class="docutils literal"><span class="pre">--query_flags</span></tt> option value to enable assignment expression.</p>
<p>Assignment expression in query syntax has some limitations. So you
should use <a class="reference internal" href="script_syntax.html"><em>Script syntax</em></a> instead of query syntax for
assignment.</p>
<p>There is only one syntax for assignment expression. It's <tt class="docutils literal"><span class="pre">column:=value</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">value</span></tt> is assigend to <tt class="docutils literal"><span class="pre">column</span></tt>. <tt class="docutils literal"><span class="pre">value</span></tt> is always processed as
string in query syntax. <tt class="docutils literal"><span class="pre">value</span></tt> is casted to the type of <tt class="docutils literal"><span class="pre">column</span></tt>
automatically. It causes some limitations. For example, you cannot use
boolean literal such as <tt class="docutils literal"><span class="pre">true</span></tt> and <tt class="docutils literal"><span class="pre">false</span></tt> for <tt class="docutils literal"><span class="pre">Bool</span></tt> type
column. You need to use empty string for <tt class="docutils literal"><span class="pre">false</span></tt> but query syntax
doesn't support <tt class="docutils literal"><span class="pre">column:=</span></tt> syntax.</p>
<p>See <a class="reference internal" href="../cast.html"><em>Cast</em></a> about cast.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">8.10.1. Query syntax</a><ul>
<li><a class="reference internal" href="#sample-data">8.10.1.1. Sample data</a></li>
<li><a class="reference internal" href="#escape">8.10.1.2. Escape</a></li>
<li><a class="reference internal" href="#conditional-expression">8.10.1.3. Conditional expression</a><ul>
<li><a class="reference internal" href="#full-text-search-condition">8.10.1.3.1. Full text search condition</a></li>
<li><a class="reference internal" href="#phrase-search-condition">8.10.1.3.2. Phrase search condition</a></li>
<li><a class="reference internal" href="#full-text-search-condition-with-explicit-match-column">8.10.1.3.3. Full text search condition (with explicit match column)</a></li>
<li><a class="reference internal" href="#phrase-search-condition-with-explicit-match-column">8.10.1.3.4. Phrase search condition (with explicit match column)</a></li>
<li><a class="reference internal" href="#prefix-search-condition">8.10.1.3.5. Prefix search condition</a></li>
<li><a class="reference internal" href="#suffix-search-condition">8.10.1.3.6. Suffix search condition</a></li>
<li><a class="reference internal" href="#equal-condition">8.10.1.3.7. Equal condition</a></li>
<li><a class="reference internal" href="#not-equal-condition">8.10.1.3.8. Not equal condition</a></li>
<li><a class="reference internal" href="#less-than-condition">8.10.1.3.9. Less than condition</a></li>
<li><a class="reference internal" href="#greater-than-condition">8.10.1.3.10. Greater than condition</a></li>
<li><a class="reference internal" href="#less-than-or-equal-to-condition">8.10.1.3.11. Less than or equal to condition</a></li>
<li><a class="reference internal" href="#greater-than-or-equal-to-condition">8.10.1.3.12. Greater than or equal to condition</a></li>
</ul>
</li>
<li><a class="reference internal" href="#combined-expression">8.10.1.4. Combined expression</a><ul>
<li><a class="reference internal" href="#logical-or">8.10.1.4.1. Logical OR</a></li>
<li><a class="reference internal" href="#logical-and">8.10.1.4.2. Logical AND</a></li>
<li><a class="reference internal" href="#logical-not">8.10.1.4.3. Logical NOT</a></li>
<li><a class="reference internal" href="#grouping">8.10.1.4.4. Grouping</a></li>
</ul>
</li>
<li><a class="reference internal" href="#assignment-expression">8.10.1.5. Assignment expression</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../grn_expr.html"
                        title="previous chapter">8.10. grn_expr</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="script_syntax.html"
                        title="next chapter">8.10.2. Script syntax</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/reference/grn_expr/query_syntax.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="script_syntax.html" title="8.10.2. Script syntax"
             >next</a> |</li>
        <li class="right" >
          <a href="../grn_expr.html" title="8.10. grn_expr"
             >previous</a> |</li>
        <li><a href="../../index.html">groonga v3.0.5 documentation</a> &raquo;</li>
          <li><a href="../../reference.html" >8. リファレンスマニュアル</a> &raquo;</li>
          <li><a href="../grn_expr.html" >8.10. grn_expr</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2013, Brazil, Inc.
    </div>
  </body>
</html>