Sophie

Sophie

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

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>4.7. match_columnsパラメータ &mdash; groonga v3.0.5ドキュメント</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>
    <script type="text/javascript" src="../_static/translations.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="top" title="groonga v3.0.5ドキュメント" href="../index.html" />
    <link rel="up" title="4. チュートリアル" href="../tutorial.html" />
    <link rel="next" title="4.8. パトリシア木による前方一致検索" href="patricia_trie.html" />
    <link rel="prev" title="4.6. タグ検索・参照関係の逆引き" href="index.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">オープンソースのカラムストア機能付き全文検索エンジン</span>
    </a>
  </h1>

  <div class="other-language-links">
    <ul>
      <li><a href="../../../en/html/tutorial/match_columns.html"><img src="../_static/us.png" alt="English">English page</a></li>
    </ul>
  </div>
</div>
  

    <div class="related">
      <h3>ナビゲーション</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="総合索引"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="patricia_trie.html" title="4.8. パトリシア木による前方一致検索"
             accesskey="N">次へ</a> |</li>
        <li class="right" >
          <a href="index.html" title="4.6. タグ検索・参照関係の逆引き"
             accesskey="P">前へ</a> |</li>
        <li><a href="../index.html">groonga v3.0.5ドキュメント</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="match-columns">
<h1>4.7. match_columnsパラメータ<a class="headerlink" href="#match-columns" title="このヘッドラインへのパーマリンク">¶</a></h1>
<div class="section" id="id1">
<h2>4.7.1. 複数のカラムを対象とした全文検索<a class="headerlink" href="#id1" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>groongaでは、複数のカラムを対象とした全文検索を行うことができます。例えば、ブログのテーブルで、タイトルと内容とがそれぞれ別のカラムに入ったものがあるとしましょう。「タイトルもしくは内容に特定の単語を含む」検索を行いたいとします。</p>
<p>この場合、2つのインデックス作成方式があります。1つは、それぞれのカラムに1つずつインデックスを付与する方式です。もう1つは、複数のカラムに対して1つのインデックスを付与する方式です。groongaでは、どちらの形式のインデックスが存在している場合でも、同一の記法で全文検索を行うことができます。</p>
<div class="section" id="id2">
<h3>4.7.1.1. カラムごとにインデックスを付与する場合<a class="headerlink" href="#id2" title="このヘッドラインへのパーマリンク">¶</a></h3>
<p>Blog1テーブルを作り、タイトル文字列のtitleカラム、本文のmessageカラムを追加しています。
インデックス用のIndexBlog1テーブルも作り、titleカラムのインデックス用にindex_titleカラム、messageカラムのインデック用にindex_messageカラムと、それぞれ1カラムごとに1つずつ追加しています。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create --name Blog1 --flags TABLE_HASH_KEY --key_type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table Blog1 --name title --flags COLUMN_SCALAR --type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table Blog1 --name message --flags COLUMN_SCALAR --type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create --name IndexBlog1 --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table IndexBlog1 --name index_title --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source title
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table IndexBlog1 --name index_message --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source message
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Blog1
[
{&quot;_key&quot;:&quot;grn1&quot;,&quot;title&quot;:&quot;groonga test&quot;,&quot;message&quot;:&quot;groonga message&quot;},
{&quot;_key&quot;:&quot;grn2&quot;,&quot;title&quot;:&quot;baseball result&quot;,&quot;message&quot;:&quot;rakutan eggs 4 - 4 groonga moritars&quot;},
{&quot;_key&quot;:&quot;grn3&quot;,&quot;title&quot;:&quot;groonga message&quot;,&quot;message&quot;:&quot;none&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
<p>match_columnsオプションで、検索対象のカラムを複数指定することが出来ます。検索する文字列はqueryオプションで指定します。これを使うことで、タイトルと本文を全文検索することができます。</p>
<p>実際に検索してみましょう。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>select --table Blog1 --match_columns title||message --query groonga
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;grn1&quot;,
#         &quot;groonga message&quot;,
#         &quot;groonga test&quot;
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ],
#       [
#         2,
#         &quot;grn2&quot;,
#         &quot;rakutan eggs 4 - 4 groonga moritars&quot;,
#         &quot;baseball result&quot;
#       ]
#     ]
#   ]
# ]
select --table Blog1 --match_columns title||message --query message
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ],
#       [
#         1,
#         &quot;grn1&quot;,
#         &quot;groonga message&quot;,
#         &quot;groonga test&quot;
#       ]
#     ]
#   ]
# ]
select --table Blog1 --match_columns title --query message
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h3>4.7.1.2. 複数のカラムにまたがったインデックスを付与する場合<a class="headerlink" href="#id3" title="このヘッドラインへのパーマリンク">¶</a></h3>
<p>内容は上の例とほぼ同じですが、titleとmessageの2つのカラムに対するインデックスが共通になっており、インデックスカラムが1つしかありません。</p>
<p>共通のインデックスを用いても、titleカラムのみでの検索、messageカラムのみでの検索、titleもしくはmessageカラムでの検索、全ての検索を行うことができます。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create --name Blog2 --flags TABLE_HASH_KEY --key_type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table Blog2 --name title --flags COLUMN_SCALAR --type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table Blog2 --name message --flags COLUMN_SCALAR --type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create --name IndexBlog2 --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create --table IndexBlog2 --name index_blog --flags COLUMN_INDEX|WITH_POSITION|WITH_SECTION --type Blog2 --source title,message
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Blog2
[
{&quot;_key&quot;:&quot;grn1&quot;,&quot;title&quot;:&quot;groonga test&quot;,&quot;message&quot;:&quot;groonga message&quot;},
{&quot;_key&quot;:&quot;grn2&quot;,&quot;title&quot;:&quot;baseball result&quot;,&quot;message&quot;:&quot;rakutan eggs 4 - 4 groonga moritars&quot;},
{&quot;_key&quot;:&quot;grn3&quot;,&quot;title&quot;:&quot;groonga message&quot;,&quot;message&quot;:&quot;none&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
<p>実際に検索してみましょう。結果は上の例と同じになります。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>select --table Blog2 --match_columns title||message --query groonga
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;grn1&quot;,
#         &quot;groonga message&quot;,
#         &quot;groonga test&quot;
#       ],
#       [
#         2,
#         &quot;grn2&quot;,
#         &quot;rakutan eggs 4 - 4 groonga moritars&quot;,
#         &quot;baseball result&quot;
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ]
#     ]
#   ]
# ]
select --table Blog2 --match_columns title||message --query message
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;grn1&quot;,
#         &quot;groonga message&quot;,
#         &quot;groonga test&quot;
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ]
#     ]
#   ]
# ]
select --table Blog2 --match_columns title --query message
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;message&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;title&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         3,
#         &quot;grn3&quot;,
#         &quot;none&quot;,
#         &quot;groonga message&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
</div>
<div class="section" id="id4">
<h2>4.7.2. インデックス名を指定した全文検索<a class="headerlink" href="#id4" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>執筆中です。</p>
</div>
<div class="section" id="nested-index-search-among-related-table-by-column-index">
<span id="nested-index-search"></span><h2>4.7.3. カラムインデックスによる関連テーブルをまたぐ検索<a class="headerlink" href="#nested-index-search-among-related-table-by-column-index" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>複数のテーブルがカラムインデックスで関連付けられているなら、参照カラム名を指定して複数のテーブルにまたがって検索することができます。</p>
<p>具体的な例を示します。</p>
<p>ブログ記事や記事のコメントを保存するテーブルがあります。記事を保存するテーブルには記事とコメントのためのカラムがあります。そしてそのコメントカラムはCommentsテーブルを参照しています。コメントを保存するテーブルにはコメントと記事テーブルに対するカラムインデックスが設定されています。</p>
<p>特定のキーワードをコメントに含む記事を探すには、コメントテーブルを全文検索する必要があり、全文検索結果を含むレコードをさらに検索する必要があります。</p>
<p>しかし、カラムインデックスを指定することで一度にレコードを検索することができます。</p>
<p>サンプルのスキーマ定義はこちらです。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create Comments TABLE_HASH_KEY UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Comments content COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Articles TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Articles content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Articles comment COLUMN_SCALAR Comments
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Lexicon TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon articles_content COLUMN_INDEX|WITH_POSITION Articles content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon comments_content COLUMN_INDEX|WITH_POSITION Comments content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Comments article COLUMN_INDEX Articles comment
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>サンプルデータはこちらです。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>load --table Comments
[
{&quot;_key&quot;: 1, &quot;content&quot;: &quot;I&#39;m using groonga too!&quot;},
{&quot;_key&quot;: 2, &quot;content&quot;: &quot;I&#39;m using groonga and mroonga!&quot;},
{&quot;_key&quot;: 3, &quot;content&quot;: &quot;I&#39;m using mroonga too!&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
load --table Articles
[
{&quot;content&quot;: &quot;Groonga is fast!&quot;, &quot;comment&quot;: 1},
{&quot;content&quot;: &quot;Groonga is useful!&quot;},
{&quot;content&quot;: &quot;Mroonga is fast!&quot;, &quot;comment&quot;: 3}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
<p>特定のキーワードをコメントに含むレコードを検索するクエリを書くことができ、それによりレコードを参照する記事を取得します。</p>
<p>これまでに記述したレコードを検索するクエリ:</p>
<div class="highlight-none"><div class="highlight"><pre>select Articles --match_columns comment.content --query groonga --output_columns &quot;_id, _score, *&quot;
</pre></div>
</div>
<p>ArticlesテーブルのcommentカラムとCommentsテーブルのcontentカラムをピリオド(.)で連結し <tt class="docutils literal"><span class="pre">--match_columns</span></tt> の引数とする必要があります。</p>
<p>最初に、このクエリはCommentsテーブルのcontentを全文検索し、次にCommentsテーブルを検索した結果のレコードを参照するArticlesテーブルのレコードを取得します。(これにより、Commentsテーブルの'article'カラムインデックスを生成するクエリをコメントアウトすると、意図した検索結果が得られません。)</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>select Articles --match_columns comment.content --query groonga --output_columns &quot;_id, _score, *&quot;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;Comments&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ]
#       ],
#       [
#         1,
#         1,
#         1,
#         &quot;Groonga is fast!&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>これで、特定のキーワードをコメントとして含む記事を検索できます。</p>
<p>このネストしたインデックスの検索という特徴には関連するテーブルが2つだけに制限されません。</p>
<p>前のものと似たサンプルのスキーマ定義です。違いは'返信'を表現するテーブルの追加と関連するテーブルが3つに増えたことです。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>table_create Replies2 TABLE_HASH_KEY UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Replies2 content COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Comments2 TABLE_HASH_KEY UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Comments2 content COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Comments2 comment COLUMN_SCALAR Replies2
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Articles2 TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Articles2 content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Articles2 comment COLUMN_SCALAR Comments2
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Lexicon2 TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon2 articles_content COLUMN_INDEX|WITH_POSITION Articles2 content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon2 comments_content COLUMN_INDEX|WITH_POSITION Comments2 content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon2 replies_content COLUMN_INDEX|WITH_POSITION Replies2 content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Comments2 article COLUMN_INDEX Articles2 comment
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Replies2 reply_to COLUMN_INDEX Comments2 comment
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>サンプルデータはこちらです。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>load --table Replies2
[
{&quot;_key&quot;: 1, &quot;content&quot;: &quot;I&#39;m using rroonga too!&quot;},
{&quot;_key&quot;: 2, &quot;content&quot;: &quot;I&#39;m using groonga and mroonga and rroonga!&quot;},
{&quot;_key&quot;: 3, &quot;content&quot;: &quot;I&#39;m using nroonga too!&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
load --table Comments2
[
{&quot;_key&quot;: 1, &quot;content&quot;: &quot;I&#39;m using groonga too!&quot;, &quot;comment&quot;: 1},
{&quot;_key&quot;: 2, &quot;content&quot;: &quot;I&#39;m using groonga and mroonga!&quot;, &quot;comment&quot;: 2},
{&quot;_key&quot;: 3, &quot;content&quot;: &quot;I&#39;m using mroonga too!&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
load --table Articles2
[
{&quot;content&quot;: &quot;Groonga is fast!&quot;, &quot;comment&quot;: 1},
{&quot;content&quot;: &quot;Groonga is useful!&quot;, &quot;comment&quot;: 2},
{&quot;content&quot;: &quot;Mroonga is fast!&quot;, &quot;comment&quot;: 3}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
<p>これまでに記述したレコードを検索するクエリ:</p>
<div class="highlight-none"><div class="highlight"><pre>select Articles2 --match_columns comment.content --query mroonga --output_columns &quot;_id, _score, *&quot;
select Articles2 --match_columns comment.comment.content --query mroonga --output_columns &quot;_id, _score, *&quot;
</pre></div>
</div>
<p>最初のクエリはComments2テーブルから'mroonga'を検索します。2つめのクエリはReplies2とComments2テーブルからカラムインデックスによる参照を用いて'mroonga'を検索します。</p>
<p>実行例:</p>
<div class="highlight-none"><div class="highlight"><pre>select Articles2 --match_columns comment.content --query mroonga --output_columns &quot;_id, _score, *&quot;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;Comments2&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ]
#       ],
#       [
#         2,
#         1,
#         2,
#         &quot;Groonga is useful!&quot;
#       ],
#       [
#         3,
#         1,
#         3,
#         &quot;Mroonga is fast!&quot;
#       ]
#     ]
#   ]
# ]
select Articles2 --match_columns comment.comment.content --query mroonga --output_columns &quot;_id, _score, *&quot;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;Comments2&quot;
#         ],
#         [
#           &quot;content&quot;,
#           &quot;Text&quot;
#         ]
#       ],
#       [
#         2,
#         1,
#         2,
#         &quot;Groonga is useful!&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>結果として、最初のクエリはComments2テーブルに'mroonga'をキーワードとして含むレコードが2つあるので、該当する記事2つにマッチします。</p>
<p>一方、2つめのクエリはReplies2テーブルに'mroonga'というキーワードにマッチするレコードが1つしかなく、Comments2テーブルでそのキーワードを含むレコードを参照するコメントが1つなので、該当する記事は1つだけとなります。</p>
</div>
<div class="section" id="id5">
<h2>4.7.4. インデックスの重み<a class="headerlink" href="#id5" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>執筆中です。</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">目次</a></h3>
  <ul>
<li><a class="reference internal" href="#">4.7. match_columnsパラメータ</a><ul>
<li><a class="reference internal" href="#id1">4.7.1. 複数のカラムを対象とした全文検索</a><ul>
<li><a class="reference internal" href="#id2">4.7.1.1. カラムごとにインデックスを付与する場合</a></li>
<li><a class="reference internal" href="#id3">4.7.1.2. 複数のカラムにまたがったインデックスを付与する場合</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id4">4.7.2. インデックス名を指定した全文検索</a></li>
<li><a class="reference internal" href="#nested-index-search-among-related-table-by-column-index">4.7.3. カラムインデックスによる関連テーブルをまたぐ検索</a></li>
<li><a class="reference internal" href="#id5">4.7.4. インデックスの重み</a></li>
</ul>
</li>
</ul>

  <h4>前のトピックへ</h4>
  <p class="topless"><a href="index.html"
                        title="前の章へ">4.6. タグ検索・参照関係の逆引き</a></p>
  <h4>次のトピックへ</h4>
  <p class="topless"><a href="patricia_trie.html"
                        title="次の章へ">4.8. パトリシア木による前方一致検索</a></p>
  <h3>このページ</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/tutorial/match_columns.txt"
           rel="nofollow">ソースコードを表示</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>クイック検索</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="検索" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    モジュール、クラス、または関数名を入力してください
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>ナビゲーション</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="総合索引"
             >索引</a></li>
        <li class="right" >
          <a href="patricia_trie.html" title="4.8. パトリシア木による前方一致検索"
             >次へ</a> |</li>
        <li class="right" >
          <a href="index.html" title="4.6. タグ検索・参照関係の逆引き"
             >前へ</a> |</li>
        <li><a href="../index.html">groonga v3.0.5ドキュメント</a> &raquo;</li>
          <li><a href="../tutorial.html" >4. チュートリアル</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2013, Brazil, Inc.
    </div>
  </body>
</html>