Sophie

Sophie

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

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>5.3. Completion &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="5. Suggest" href="../suggest.html" />
    <link rel="next" title="5.4. Correction" href="correction.html" />
    <link rel="prev" title="5.2. Tutorial" href="tutorial.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/suggest/completion.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="correction.html" title="5.4. Correction"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="5.2. Tutorial"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">groonga v3.0.5 documentation</a> &raquo;</li>
          <li><a href="../suggest.html" accesskey="U">5. Suggest</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="completion">
<h1>5.3. Completion<a class="headerlink" href="#completion" title="Permalink to this headline">¶</a></h1>
<p>This section describes about the following completion
features:</p>
<ul class="simple">
<li>How it works</li>
<li>How to use</li>
<li>How to learn</li>
</ul>
<div class="section" id="how-it-works">
<h2>5.3.1. How it works<a class="headerlink" href="#how-it-works" title="Permalink to this headline">¶</a></h2>
<p>The completion feature uses three searches to compute
completed words:</p>
<blockquote>
<div><ol class="arabic simple">
<li>Prefix RK search against registered words.</li>
<li>Cooccurrence search against learned data.</li>
<li>Prefix search against registered words. (optional)</li>
</ol>
</div></blockquote>
<div class="section" id="prefix-rk-search">
<h3>5.3.1.1. Prefix RK search<a class="headerlink" href="#prefix-rk-search" title="Permalink to this headline">¶</a></h3>
<p>RK means Romaji and Katakana. Prefix RK search can find
registered words that start with user's input by romaji,
katakana or hiragana. It's useful for searching in Japanese.</p>
<p>For example, there is a registered word &quot;日本&quot;. And &quot;ニホン&quot;
(it must be katakana) is registered as its reading. An user
can find &quot;日本&quot; by &quot;ni&quot;, &quot;二&quot; or &quot;に&quot;.</p>
</div>
<div class="section" id="cooccurrence-search">
<h3>5.3.1.2. Cooccurrence search<a class="headerlink" href="#cooccurrence-search" title="Permalink to this headline">¶</a></h3>
<p>Cooccurrence search can find registered words from user's
partial input. It uses user input sequences that will be
learned from query logs, access logs and so on.</p>
<p>For example, there is the following user input sequence:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">input</th>
<th class="head">submit</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>s</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>se</td>
<td>no</td>
</tr>
<tr class="row-even"><td>sea</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>sear</td>
<td>no</td>
</tr>
<tr class="row-even"><td>searc</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>search</td>
<td>yes</td>
</tr>
<tr class="row-even"><td>e</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>en</td>
<td>no</td>
</tr>
<tr class="row-even"><td>eng</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>engi</td>
<td>no</td>
</tr>
<tr class="row-even"><td>engin</td>
<td>no</td>
</tr>
<tr class="row-odd"><td>engine</td>
<td>no</td>
</tr>
<tr class="row-even"><td>enginen</td>
<td>no (typo!)</td>
</tr>
<tr class="row-odd"><td>engine</td>
<td>yes</td>
</tr>
</tbody>
</table>
<p>Groonga creates the following completion pairs:</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">input</th>
<th class="head">completed word</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>s</td>
<td>search</td>
</tr>
<tr class="row-odd"><td>se</td>
<td>search</td>
</tr>
<tr class="row-even"><td>sea</td>
<td>search</td>
</tr>
<tr class="row-odd"><td>sear</td>
<td>search</td>
</tr>
<tr class="row-even"><td>searc</td>
<td>search</td>
</tr>
<tr class="row-odd"><td>e</td>
<td>engine</td>
</tr>
<tr class="row-even"><td>en</td>
<td>engine</td>
</tr>
<tr class="row-odd"><td>eng</td>
<td>engine</td>
</tr>
<tr class="row-even"><td>engi</td>
<td>engine</td>
</tr>
<tr class="row-odd"><td>engin</td>
<td>engine</td>
</tr>
<tr class="row-even"><td>engine</td>
<td>engine</td>
</tr>
<tr class="row-odd"><td>enginen</td>
<td>engine</td>
</tr>
</tbody>
</table>
<p>All user not-submitted inputs (e.g. &quot;s&quot;, &quot;se&quot; and so on)
before each an user submission maps to the submitted input
(e.g. &quot;search&quot;).</p>
<p>To be precise, this description isn't correct because it
omits about time stamp. Groonga doesn't case about &quot;all user
not-submitted inputs before each an user
submission&quot;. Groonga just case about &quot;all user not-submitted
inputs within a minute from an user submission before each
an user submission&quot;. Groonga doesn't treat user inputs
before a minute ago.</p>
<p>If an user inputs &quot;sea&quot; and cooccurrence search returns
&quot;search&quot; because &quot;sea&quot; is in input column and corresponding
completed word column value is &quot;search&quot;.</p>
</div>
<div class="section" id="prefix-search">
<h3>5.3.1.3. Prefix search<a class="headerlink" href="#prefix-search" title="Permalink to this headline">¶</a></h3>
<p>Prefix search can find registered word that start with
user's input. This search doesn't care about romaji,
katakana and hiragana not like Prefix RK search.</p>
<p>This search isn't always ran. It's just ran when it's
requested explicitly or both prefix RK search and
cooccurrence search return nothing.</p>
<p>For example, there is a registered word &quot;search&quot;. An user
can find &quot;search&quot; by &quot;s&quot;, &quot;se&quot;, &quot;sea&quot;, &quot;sear&quot;, &quot;searc&quot; and
&quot;search&quot;.</p>
</div>
</div>
<div class="section" id="how-to-use">
<h2>5.3.2. How to use<a class="headerlink" href="#how-to-use" title="Permalink to this headline">¶</a></h2>
<p>Groonga provides <a class="reference internal" href="../reference/commands/suggest.html"><em>suggest</em></a> command to use
completion. <cite>--type complete</cite> option requests completion.</p>
<p>For example, here is an command to get completion results by
&quot;en&quot;:</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>suggest --table item_query --column kana --types complete --frequency_threshold 1 --query en
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   {
#     &quot;complete&quot;: [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;engine&quot;,
#         1
#       ]
#     ]
#   }
# ]
</pre></div>
</div>
</div>
<div class="section" id="how-it-learns">
<h2>5.3.3. How it learns<a class="headerlink" href="#how-it-learns" title="Permalink to this headline">¶</a></h2>
<p>Cooccurrence search uses learned data. They are based on
query logs, access logs and so on. To create learned data,
groonga needs user input sequence with time stamp and user
submit input with time stamp.</p>
<p>For example, an user wants to search by &quot;engine&quot;. The user
inputs the query with the following sequence:</p>
<blockquote>
<div><ol class="arabic simple">
<li>2011-08-10T13:33:23+09:00: e</li>
<li>2011-08-10T13:33:23+09:00: en</li>
<li>2011-08-10T13:33:24+09:00: eng</li>
<li>2011-08-10T13:33:24+09:00: engi</li>
<li>2011-08-10T13:33:24+09:00: engin</li>
<li>2011-08-10T13:33:25+09:00: engine (submit!)</li>
</ol>
</div></blockquote>
<p>Groonga can be learned from the input sequence by the
following command:</p>
<div class="highlight-none"><div class="highlight"><pre>load --table event_query --each &#39;suggest_preparer(_id, type, item, sequence, time, pair_query)&#39;
[
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950803.86057, &quot;item&quot;: &quot;e&quot;},
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950803.96857, &quot;item&quot;: &quot;en&quot;},
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950804.26057, &quot;item&quot;: &quot;eng&quot;},
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950804.56057, &quot;item&quot;: &quot;engi&quot;},
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950804.76057, &quot;item&quot;: &quot;engin&quot;},
{&quot;sequence&quot;: &quot;1&quot;, &quot;time&quot;: 1312950805.86057, &quot;item&quot;: &quot;engine&quot;, &quot;type&quot;: &quot;submit&quot;}
]
</pre></div>
</div>
</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="#">5.3. Completion</a><ul>
<li><a class="reference internal" href="#how-it-works">5.3.1. How it works</a><ul>
<li><a class="reference internal" href="#prefix-rk-search">5.3.1.1. Prefix RK search</a></li>
<li><a class="reference internal" href="#cooccurrence-search">5.3.1.2. Cooccurrence search</a></li>
<li><a class="reference internal" href="#prefix-search">5.3.1.3. Prefix search</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-use">5.3.2. How to use</a></li>
<li><a class="reference internal" href="#how-it-learns">5.3.3. How it learns</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="tutorial.html"
                        title="previous chapter">5.2. Tutorial</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="correction.html"
                        title="next chapter">5.4. Correction</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/suggest/completion.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="correction.html" title="5.4. Correction"
             >next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="5.2. Tutorial"
             >previous</a> |</li>
        <li><a href="../index.html">groonga v3.0.5 documentation</a> &raquo;</li>
          <li><a href="../suggest.html" >5. Suggest</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2013, Brazil, Inc.
    </div>
  </body>
</html>