Sophie

Sophie

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

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.8.1. QueryExpanderTSV &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.8. Query expanders" href="../query_expanders.html" />
    <link rel="next" title="8.9. 疑似カラム (pseudo_column)" href="../pseudo_column.html" />
    <link rel="prev" title="8.8. Query expanders" href="../query_expanders.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/query_expanders/tsv.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="../pseudo_column.html" title="8.9. 疑似カラム (pseudo_column)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../query_expanders.html" title="8.8. Query expanders"
             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="../query_expanders.html" accesskey="U">8.8. Query expanders</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="queryexpandertsv">
<h1>8.8.1. QueryExpanderTSV<a class="headerlink" href="#queryexpandertsv" title="Permalink to this headline">¶</a></h1>
<div class="section" id="summary">
<h2>8.8.1.1. Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<p><tt class="docutils literal"><span class="pre">QueryExpanderTSV</span></tt> is a query expander plugin that reads synonyms
from TSV (Tab Separated Values) file. This plugin provides poor
feature than the embedded query expansion feature. For example, it
doesn't support word normalization. But it may be easy to use because
you can manage your synonyms by TSV file. You can edit your synonyms
by spreadsheet application such as Excel. With the embedded query
expansion feature, you manage your synonyms by groonga's table.</p>
</div>
<div class="section" id="install">
<h2>8.8.1.2. Install<a class="headerlink" href="#install" title="Permalink to this headline">¶</a></h2>
<p>You need to register <tt class="docutils literal"><span class="pre">query_expanders/tsv</span></tt> as a plugin before you
use <tt class="docutils literal"><span class="pre">QueryExpanderTSV</span></tt>:</p>
<div class="highlight-none"><div class="highlight"><pre>register query_expanders/tsv
</pre></div>
</div>
</div>
<div class="section" id="usage">
<h2>8.8.1.3. Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>You just add <tt class="docutils literal"><span class="pre">--query_expansion</span> <span class="pre">QueryExpanderTSV</span></tt> parameter to
<tt class="docutils literal"><span class="pre">select</span></tt> command:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;QUERY&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>If <tt class="docutils literal"><span class="pre">QUERY</span></tt> has registered synonyms, they are expanded. For example,
there are the following synonyms.</p>
<table border="1" class="docutils">
<colgroup>
<col width="38%" />
<col width="32%" />
<col width="30%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">word</th>
<th class="head">synonym 1</th>
<th class="head">synonym 2</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>groonga</td>
<td>groonga</td>
<td>Senna</td>
</tr>
<tr class="row-odd"><td>mroonga</td>
<td>mroonga</td>
<td>groonga MySQL</td>
</tr>
</tbody>
</table>
<p>The table means that <tt class="docutils literal"><span class="pre">synonym</span> <span class="pre">1</span></tt> and <tt class="docutils literal"><span class="pre">synonym</span> <span class="pre">2</span></tt> are synonyms of
<tt class="docutils literal"><span class="pre">word</span></tt>. For example, <tt class="docutils literal"><span class="pre">groonga</span></tt> and <tt class="docutils literal"><span class="pre">Senna</span></tt> are synonyms of
<tt class="docutils literal"><span class="pre">groonga</span></tt>. And <tt class="docutils literal"><span class="pre">mroonga</span></tt> and <tt class="docutils literal"><span class="pre">groonga</span> <span class="pre">MySQL</span></tt> are synonyms of
<tt class="docutils literal"><span class="pre">mroonga</span></tt>.</p>
<p>Here is an example of query expnasion that uses <tt class="docutils literal"><span class="pre">groonga</span></tt> as query:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;groonga&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>The above command equals to the following command:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;groonga OR Senna&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>Here is another example of query expnasion that uses <tt class="docutils literal"><span class="pre">mroonga</span>
<span class="pre">search</span></tt> as query:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;mroonga search&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>The above command equals to the following command:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;(mroonga OR (groonga MySQL)) search&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>It is important that registered words (<tt class="docutils literal"><span class="pre">groonga</span></tt> and <tt class="docutils literal"><span class="pre">mroonga</span></tt>)
are only expanded to synonyms and not registered words (<tt class="docutils literal"><span class="pre">search</span></tt>)
are not expanded. Query expansion isn't occurred
recursively. <tt class="docutils literal"><span class="pre">groonga</span></tt> is appeared in <tt class="docutils literal"><span class="pre">(mroonga</span> <span class="pre">OR</span> <span class="pre">(groonga</span>
<span class="pre">MySQL))</span></tt> as query expansion result but it isn't expanded.</p>
<p>Normally, you need to include <tt class="docutils literal"><span class="pre">word</span></tt> itself into synonyms. For
example, <tt class="docutils literal"><span class="pre">groonga</span></tt> and <tt class="docutils literal"><span class="pre">mroonga</span></tt> are included in synonyms of
themselves. If you want to ignore <tt class="docutils literal"><span class="pre">word</span></tt> itself, you don't include
<tt class="docutils literal"><span class="pre">word</span></tt> itself into synonyms. For example, if you want to use query
expansion as spelling correction, you should use the following
synonyms.</p>
<table border="1" class="docutils">
<colgroup>
<col width="54%" />
<col width="46%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">word</th>
<th class="head">synonym</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>gronga</td>
<td>groonga</td>
</tr>
</tbody>
</table>
<p><tt class="docutils literal"><span class="pre">gronga</span></tt> in <tt class="docutils literal"><span class="pre">word</span></tt> has a typo. A <tt class="docutils literal"><span class="pre">o</span></tt> is missing. <tt class="docutils literal"><span class="pre">groonga</span></tt> in
<tt class="docutils literal"><span class="pre">synonym</span></tt> is the correct word.</p>
<p>Here is an example of using query expnasion as spelling correction:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;gronga&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>The above command equals to the following command:</p>
<div class="highlight-none"><div class="highlight"><pre>select --query &quot;groonga&quot; --query_expansion QueryExpanderTSV
</pre></div>
</div>
<p>The former command has a typo in <tt class="docutils literal"><span class="pre">--query</span></tt> value but the latter
command doesn't have any typos.</p>
</div>
<div class="section" id="tsv-file">
<h2>8.8.1.4. TSV File<a class="headerlink" href="#tsv-file" title="Permalink to this headline">¶</a></h2>
<p>Synonyms are defined in TSV format file. This section describes about
it.</p>
<div class="section" id="location">
<h3>8.8.1.4.1. Location<a class="headerlink" href="#location" title="Permalink to this headline">¶</a></h3>
<p>The file name should be <tt class="docutils literal"><span class="pre">synonyms.tsv</span></tt> and it is located at
configuration directory. For example, <tt class="docutils literal"><span class="pre">/etc/groonga/synonyms.tsv</span></tt> is
a TSV file location. The location is decided at build time.</p>
<p>You can change the location by environment variable
<tt class="docutils literal"><span class="pre">GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE</span></tt> at run time:</p>
<div class="highlight-none"><div class="highlight"><pre>% env GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/tmp/synonyms.tsv groonga
</pre></div>
</div>
<p>With the above command, <tt class="docutils literal"><span class="pre">/tmp/synonyms.tsv</span></tt> file is used.</p>
</div>
<div class="section" id="format">
<h3>8.8.1.4.2. Format<a class="headerlink" href="#format" title="Permalink to this headline">¶</a></h3>
<p>You can define zero or more synonyms in a TSV file. You define a
<tt class="docutils literal"><span class="pre">word</span></tt> and <tt class="docutils literal"><span class="pre">synonyms</span></tt> pair by a line. <tt class="docutils literal"><span class="pre">word</span></tt> is expanded to
<tt class="docutils literal"><span class="pre">synonyms</span></tt> in <tt class="docutils literal"><span class="pre">--query</span></tt> value. <tt class="docutils literal"><span class="pre">Synonyms</span></tt> are combined by
<tt class="docutils literal"><span class="pre">OR</span></tt>. For example, <tt class="docutils literal"><span class="pre">groonga</span></tt> and <tt class="docutils literal"><span class="pre">Senna</span></tt> synonyms are expanded
as <tt class="docutils literal"><span class="pre">groonga</span> <span class="pre">OR</span> <span class="pre">Senna</span></tt>.</p>
<p>The first column is <tt class="docutils literal"><span class="pre">word</span></tt> and the rest columns are <tt class="docutils literal"><span class="pre">synonyms</span></tt> of
the <tt class="docutils literal"><span class="pre">word</span></tt>. Here is a sample line for <tt class="docutils literal"><span class="pre">word</span></tt> is <tt class="docutils literal"><span class="pre">groonga</span></tt> and
<tt class="docutils literal"><span class="pre">synonyms</span></tt> are <tt class="docutils literal"><span class="pre">groonga</span></tt> and <tt class="docutils literal"><span class="pre">Senna</span></tt>. <tt class="docutils literal"><span class="pre">(TAB)</span></tt> means a tab
character (<tt class="docutils literal"><span class="pre">U+0009</span></tt>):</p>
<div class="highlight-none"><div class="highlight"><pre>groonga(TAB)groonga(TAB)Senna
</pre></div>
</div>
<p>Comment line is supported. Lines that start with <tt class="docutils literal"><span class="pre">#</span></tt> are ignored.
Here is an example for comment line. <tt class="docutils literal"><span class="pre">groonga</span></tt> line is ignored as
comment line:</p>
<div class="highlight-none"><div class="highlight"><pre>#groonga(TAB)groonga(TAB)Senna
mroonga(TAB)mroonga(TAB)groonga MySQL
</pre></div>
</div>
</div>
</div>
<div class="section" id="limitation">
<h2>8.8.1.5. Limitation<a class="headerlink" href="#limitation" title="Permalink to this headline">¶</a></h2>
<p>You need to restart groonga to reload your synonyms. TSV file is
loaded only at the plugin load time.</p>
</div>
<div class="section" id="see-also">
<h2>8.8.1.6. See also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<blockquote>
<div><ul class="simple">
<li><a class="reference internal" href="../commands/select.html#query-expansion"><em>query_expansion</em></a></li>
</ul>
</div></blockquote>
</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.8.1. QueryExpanderTSV</a><ul>
<li><a class="reference internal" href="#summary">8.8.1.1. Summary</a></li>
<li><a class="reference internal" href="#install">8.8.1.2. Install</a></li>
<li><a class="reference internal" href="#usage">8.8.1.3. Usage</a></li>
<li><a class="reference internal" href="#tsv-file">8.8.1.4. TSV File</a><ul>
<li><a class="reference internal" href="#location">8.8.1.4.1. Location</a></li>
<li><a class="reference internal" href="#format">8.8.1.4.2. Format</a></li>
</ul>
</li>
<li><a class="reference internal" href="#limitation">8.8.1.5. Limitation</a></li>
<li><a class="reference internal" href="#see-also">8.8.1.6. See also</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../query_expanders.html"
                        title="previous chapter">8.8. Query expanders</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../pseudo_column.html"
                        title="next chapter">8.9. 疑似カラム (pseudo_column)</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/reference/query_expanders/tsv.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="../pseudo_column.html" title="8.9. 疑似カラム (pseudo_column)"
             >next</a> |</li>
        <li class="right" >
          <a href="../query_expanders.html" title="8.8. Query expanders"
             >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="../query_expanders.html" >8.8. Query expanders</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2013, Brazil, Inc.
    </div>
  </body>
</html>