Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 03663abacfb5829946c324cb3e985338 > files > 236

groonga-doc-1.2.7-1.fc14.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>4.11. クエリ拡張 &mdash; groonga v1.2.6 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:     '1.2.6',
        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 v1.2.6 documentation" href="../index.html" />
    <link rel="up" title="4. チュートリアル" href="../tutorial.html" />
    <link rel="next" title="5. Suggest" href="../suggest.html" />
    <link rel="prev" title="4.10. マイクロブログ検索システムの作成" href="micro_blog.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/tutorial/query_expansion.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="../suggest.html" title="5. Suggest"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="micro_blog.html" title="4.10. マイクロブログ検索システムの作成"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">groonga v1.2.6 documentation</a> &raquo;</li>
          <li><a href="../tutorial.html" accesskey="U">4. チュートリアル</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="id1">
<h1>4.11. クエリ拡張<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>groongaでは、 <a class="reference internal" href="../commands/select.html"><em>select</em></a> コマンドにquery_expansionパラメータを指定することによって、ユーザが指定した検索文字列を適宜拡張することが可能です。</p>
<p>たとえば、ユーザが'シークヮーサー'という文字列で検索した場合に、'シークヮーサー OR シークァーサー'で検索した場合と同一の結果を返すことによって、本来ユーザが必要とする結果をよりもれなく検索できるようになります。</p>
<div class="section" id="id2">
<h2>4.11.1. 準備<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>クエリ拡張機能を使用するためには、検索対象となる文書を格納するテーブル(ここでは文書テーブルと呼びます)以外に、ユーザの指定した検索文字列を置換するためのテーブル(ここでは置換テーブルと呼びます)を準備します。置換テーブルでは、その主キーが置換前の文字列となり、文字列型(ShortText)のカラムの値が置換後の文字列となります。</p>
<p>実際に文書テーブルと置換テーブルを作成してみましょう。</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>&gt; table_create Doc TABLE_PAT_KEY ShortText
[[0,1317212801.95257,0.054058921],true]
&gt; column_create Doc body COLUMN_SCALAR ShortText
[[0,1317212802.2071,0.040301713],true]
&gt; table_create Term TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
[[0,1317212802.44812,0.027340933],true]
&gt; column_create Term Doc_body COLUMN_INDEX|WITH_POSITION Doc body
[[0,1317212802.676,0.079743674],true]
&gt; table_create Synonym TABLE_PAT_KEY ShortText
[[0,1317212802.95629,0.03656858],true]
&gt; column_create Synonym body COLUMN_SCALAR ShortText
[[0,1317212803.19316,0.040515932],true]
&gt; load --table Doc
&gt; [
&gt; {&quot;_key&quot;: &quot;001&quot;, &quot;body&quot;: &quot;すっぱいブドウと甘いシークァーサー&quot;},
&gt; {&quot;_key&quot;: &quot;002&quot;, &quot;body&quot;: &quot;シークヮーサージュースとゴーヤチャンプル&quot;},
&gt; ]
[[0,1317212803.43422,0.80056314],2]
&gt; load --table Synonym
&gt; [
&gt; {&quot;_key&quot;: &quot;シークァーサー&quot;, &quot;body&quot;: &quot;(シークァーサー OR シークヮーサー)&quot;},
&gt; {&quot;_key&quot;: &quot;シークヮーサー&quot;, &quot;body&quot;: &quot;(シークァーサー OR シークヮーサー)&quot;},
&gt; ]
[[0,1317212804.43524,0.801037492],2]
</pre></div>
</div>
<p>この例では、ユーザが&quot;シークァーサー&quot;と入力しても、&quot;シークヮーサー&quot;と入力しても、それぞれの異なる表記の文書をもれなく検索するための置換テーブルを作成しています。</p>
</div>
<div class="section" id="id3">
<h2>4.11.2. 検索<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>それでは実際に、準備した置換テーブルを使ってみましょう。まずは、query_expansionパラメータを指定せずにselectコマンドを使って検索してみます。</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>&gt; select Doc --match_columns body --query &quot;シークァーサー&quot;
[[0,1317212805.4371,0.000567851],[[[1],[[&quot;_id&quot;,&quot;UInt32&quot;],[&quot;_key&quot;,&quot;ShortText&quot;],[&quot;body&quot;,&quot;ShortText&quot;]],[1,&quot;001&quot;,&quot;すっぱいブドウと甘いシークァーサー&quot;]]]]
&gt; select Doc --match_columns body --query &quot;シークヮーサー&quot;
[[0,1317212805.63859,0.000387831],[[[1],[[&quot;_id&quot;,&quot;UInt32&quot;],[&quot;_key&quot;,&quot;ShortText&quot;],[&quot;body&quot;,&quot;ShortText&quot;]],[2,&quot;002&quot;,&quot;シークヮーサージュースとゴーヤチャンプル&quot;]]]]
</pre></div>
</div>
<p>指定された文字列に完全に一致するレコードのみがそれぞれヒットします。次に、query_expansionパラメータに、準備したSynonymテーブルのbodyカラムを指定してみましょう。</p>
<p>Execution example:</p>
<div class="highlight-none"><div class="highlight"><pre>&gt; select Doc --match_columns body --query &quot;シークァーサー&quot; --query_expansion Synonym.body
[[0,1317212805.84016,0.000441852],[[[2],[[&quot;_id&quot;,&quot;UInt32&quot;],[&quot;_key&quot;,&quot;ShortText&quot;],[&quot;body&quot;,&quot;ShortText&quot;]],[1,&quot;001&quot;,&quot;すっぱいブドウと甘いシークァーサー&quot;],[2,&quot;002&quot;,&quot;シークヮーサージュースとゴーヤチャンプル&quot;]]]]
&gt; select Doc --match_columns body --query &quot;シークヮーサー&quot; --query_expansion Synonym.body
[[0,1317212806.04176,0.000580261],[[[2],[[&quot;_id&quot;,&quot;UInt32&quot;],[&quot;_key&quot;,&quot;ShortText&quot;],[&quot;body&quot;,&quot;ShortText&quot;]],[1,&quot;001&quot;,&quot;すっぱいブドウと甘いシークァーサー&quot;],[2,&quot;002&quot;,&quot;シークヮーサージュースとゴーヤチャンプル&quot;]]]]
</pre></div>
</div>
<p>どちらのクエリ文字列も、&quot;(シークァーサー OR シークヮーサー)&quot;という文字列に置換されてから検索されるため、表記の揺れを吸収して検索できるようになりました。</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="#">4.11. クエリ拡張</a><ul>
<li><a class="reference internal" href="#id2">4.11.1. 準備</a></li>
<li><a class="reference internal" href="#id3">4.11.2. 検索</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="micro_blog.html"
                        title="previous chapter">4.10. マイクロブログ検索システムの作成</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../suggest.html"
                        title="next chapter">5. Suggest</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/tutorial/query_expansion.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" size="18" />
      <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="../suggest.html" title="5. Suggest"
             >next</a> |</li>
        <li class="right" >
          <a href="micro_blog.html" title="4.10. マイクロブログ検索システムの作成"
             >previous</a> |</li>
        <li><a href="../index.html">groonga v1.2.6 documentation</a> &raquo;</li>
          <li><a href="../tutorial.html" >4. チュートリアル</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2011, Brazil, Inc.
    </div>
  </body>
</html>