<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="fulltext-search-mecab">
      </a>
      14.9.9 MeCab Full-Text Parser Plugin
     </h3>
    </div>
   </div>
  </div>
  <p>
   The built-in MySQL full-text parser uses the white space between
        words as a delimiter to determine where words begin and end,
        which is a limitation when working with ideographic languages
        that do not use word delimiters. To address this limitation for
        Japanese, MySQL provides a MeCab full-text parser plugin. The
        MeCab full-text parser plugin is supported for use with
   <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
    <code class="literal">
     InnoDB
    </code>
   </a>
   and
   <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
    <code class="literal">
     MyISAM
    </code>
   </a>
   .
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    MySQL also provides an ngram full-text parser plugin that
          supports Japanese. For more information, see
    <a class="xref" href="fulltext-search-ngram.html" title="14.9.8 ngram Full-Text Parser">
     Section 14.9.8, “ngram Full-Text Parser”
    </a>
    .
   </p>
  </div>
  <p>
   The MeCab full-text parser plugin is a full-text parser plugin
        for Japanese that tokenizes a sequence of text into meaningful
        words. For example, MeCab tokenizes
   <span class="quote">
    “
    <span class="quote">
     <span class="phrase" lang="ja">
      データベース管理
     </span>
    </span>
    ”
   </span>
   (
   <span class="quote">
    “
    <span class="quote">
     Database Management
    </span>
    ”
   </span>
   ) into
   <span class="quote">
    “
    <span class="quote">
     <span class="phrase" lang="ja">
      データベース
     </span>
    </span>
    ”
   </span>
   (
   <span class="quote">
    “
    <span class="quote">
     Database
    </span>
    ”
   </span>
   ) and
   <span class="quote">
    “
    <span class="quote">
     <span class="phrase" lang="ja">
      管理
     </span>
    </span>
    ”
   </span>
   (
   <span class="quote">
    “
    <span class="quote">
     Management
    </span>
    ”
   </span>
   ). By comparison, the
   <a class="link" href="fulltext-search-ngram.html" title="14.9.8 ngram Full-Text Parser">
    ngram
   </a>
   full-text
        parser tokenizes text into a contiguous sequence of
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   characters, where
   <em class="replaceable">
    <code>
     n
    </code>
   </em>
   represents a number between 1 and
        10.
  </p>
  <p>
   In addition to tokenizing text into meaningful words, MeCab
        indexes are typically smaller than ngram indexes, and MeCab
        full-text searches are generally faster. One drawback is that it
        may take longer for the MeCab full-text parser to tokenize
        documents, compared to the ngram full-text parser.
  </p>
  <p>
   The full-text search syntax described in
   <a class="xref" href="fulltext-search.html" title="14.9 Full-Text Search Functions">
    Section 14.9, “Full-Text Search Functions”
   </a>
   applies to the MeCab parser
        plugin. Differences in parsing behavior are described in this
        section. Full-text related configuration options are also
        applicable.
  </p>
  <p>
   For additional information about the MeCab parser, refer to the
   <a class="ulink" href="http://taku910.github.io/mecab/" target="_blank">
    MeCab: Yet Another
        Part-of-Speech and Morphological Analyzer
   </a>
   project on
        Github.
  </p>
  <h4>
   <a name="idm46045201195488">
   </a>
   Installing the MeCab Parser Plugin
  </h4>
  <p>
   The MeCab parser plugin requires
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   .
  </p>
  <p>
   On supported Fedora, Debian and Ubuntu platforms (except Ubuntu
        12.04 where the system
   <code class="filename">
    mecab
   </code>
   version is too
        old), MySQL dynamically links to the system
   <code class="filename">
    mecab
   </code>
   installation if it is installed to
        the default location. On other supported Unix-like platforms,
   <code class="filename">
    libmecab.so
   </code>
   is statically linked in
   <code class="filename">
    libpluginmecab.so
   </code>
   , which is located in the
        MySQL plugin directory.
   <code class="filename">
    mecab-ipadic
   </code>
   is
        included in MySQL binaries and is located in
   <code class="filename">
    <em class="replaceable">
     <code>
      MYSQL_HOME
     </code>
    </em>
    \lib\mecab
   </code>
   .
  </p>
  <p>
   You can install
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   using a native package
        management utility (on Fedora, Debian, and Ubuntu), or you can
        build
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   from source. For information
        about installing
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   using a native package
        management utility, see
   <a class="link" href="fulltext-search-mecab.html#install-mecab-binary" title="Installing MeCab From a Binary Distribution (Optional)">
    Installing MeCab From a
        Binary Distribution (Optional)
   </a>
   . If you want to build
   <code class="filename">
    mecab
   </code>
   and
   <code class="literal">
    mecab-ipadic
   </code>
   from source, see
   <a class="link" href="fulltext-search-mecab.html#build-mecab-from-source" title="Installing MeCab From Source (Optional)">
    Building MeCab From
        Source (Optional)
   </a>
   .
  </p>
  <p>
   On Windows,
   <code class="filename">
    libmecab.dll
   </code>
   is found in the
        MySQL
   <code class="filename">
    bin
   </code>
   directory.
   <code class="filename">
    mecab-ipadic
   </code>
   is located in
   <code class="filename">
    <em class="replaceable">
     <code>
      MYSQL_HOME
     </code>
    </em>
    /lib/mecab
   </code>
   .
  </p>
  <p>
   To install and configure the MeCab parser plugin, perform the
        following steps:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      In the MySQL configuration file, set the
      <a class="link" href="server-system-variables.html#sysvar_mecab_rc_file">
       <code class="literal">
        mecab_rc_file
       </code>
      </a>
      configuration
            option to the location of the
      <code class="literal">
       mecabrc
      </code>
      configuration file, which is the configuration file for
            MeCab. If you are using the MeCab package distributed with
            MySQL, the
      <code class="literal">
       mecabrc
      </code>
      file is located in
      <code class="filename">
       MYSQL_HOME/lib/mecab/etc/
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa21672714"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">loose-mecab-rc-file</span><span class="token attr-value"><span class="token punctuation">=</span>MYSQL_HOME/lib/mecab/etc/mecabrc</span></code></pre>
     </div>
     <p>
      The
      <code class="literal">
       loose
      </code>
      prefix is an
      <a class="link" href="option-modifiers.html" title="6.2.2.4 Program Option Modifiers">
       option modifier
      </a>
      . The
      <a class="link" href="server-system-variables.html#sysvar_mecab_rc_file">
       <code class="literal">
        mecab_rc_file
       </code>
      </a>
      option is not
            recognized by MySQL until the MeCaB parser plugin is
            installed but it must be set before attempting to install
            the MeCaB parser plugin. The
      <code class="literal">
       loose
      </code>
      prefix
            allows you restart MySQL without encountering an error due
            to an unrecognized variable.
     </p>
     <p>
      If you use your own MeCab installation, or build MeCab from
            source, the location of the
      <code class="filename">
       mecabrc
      </code>
      configuration file may differ.
     </p>
     <p>
      For information about the MySQL configuration file and its
            location, see
      <a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
       Section 6.2.2.2, “Using Option Files”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Also in the MySQL configuration file, set the minimum token
            size to 1 or 2, which are the values recommended for use
            with the MeCab parser. For
      <code class="literal">
       InnoDB
      </code>
      tables,
            minimum token size is defined by the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_ft_min_token_size">
       <code class="literal">
        innodb_ft_min_token_size
       </code>
      </a>
      configuration option, which has a default value of 3. For
      <code class="literal">
       MyISAM
      </code>
      tables, minimum token size is
            defined by
      <a class="link" href="server-system-variables.html#sysvar_ft_min_word_len">
       <code class="literal">
        ft_min_word_len
       </code>
      </a>
      ,
            which has a default value of 4.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa32681041"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">innodb_ft_min_token_size</span><span class="token attr-value"><span class="token punctuation">=</span>1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Modify the
      <code class="filename">
       mecabrc
      </code>
      configuration file
            to specify the dictionary you want to use. The
      <code class="filename">
       mecab-ipadic
      </code>
      package distributed with
            MySQL binaries includes three dictionaries
            (
      <code class="literal">
       ipadic_euc-jp
      </code>
      ,
      <code class="literal">
       ipadic_sjis
      </code>
      , and
      <code class="literal">
       ipadic_utf-8
      </code>
      ). The
      <code class="filename">
       mecabrc
      </code>
      configuration file packaged
            with MySQL contains and entry similar to the following:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa41879727"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">dicdir</span> <span class="token attr-value"><span class="token punctuation">=</span>  /path/to/mysql/lib/mecab/lib/mecab/dic/ipadic_euc-jp</span></code></pre>
     </div>
     <p>
      To use the
      <code class="filename">
       ipadic_utf-8
      </code>
      dictionary, for
            example, modify the entry as follows:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa56210312"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">dicdir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">MYSQL_HOME</em>/lib/mecab/dic/ipadic_utf-8</span></code></pre>
     </div>
     <p>
      If you are using your own MeCab installation or have built
            MeCab from source, the default
      <code class="literal">
       dicdir
      </code>
      entry in the
      <code class="filename">
       mecabrc
      </code>
      file is likely to
            differ, as are the dictionaries and their location.
     </p>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       After the MeCab parser plugin is installed, you can use
              the
       <a class="link" href="server-status-variables.html#statvar_mecab_charset">
        <code class="literal">
         mecab_charset
        </code>
       </a>
       status
              variable to view the character set used with MeCab. The
              three MeCab dictionaries provided with the MySQL binary
              support the following character sets.
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: disc; ">
        <li class="listitem">
         <p>
          The
          <code class="literal">
           ipadic_euc-jp
          </code>
          dictionary
                  supports the
          <code class="literal">
           ujis
          </code>
          and
          <code class="literal">
           eucjpms
          </code>
          character sets.
         </p>
        </li>
        <li class="listitem">
         <p>
          The
          <code class="literal">
           ipadic_sjis
          </code>
          dictionary supports
                  the
          <code class="literal">
           sjis
          </code>
          and
          <code class="literal">
           cp932
          </code>
          character sets.
         </p>
        </li>
        <li class="listitem">
         <p>
          The
          <code class="literal">
           ipadic_utf-8
          </code>
          dictionary
                  supports the
          <code class="literal">
           utf8mb3
          </code>
          and
          <code class="literal">
           utf8mb4
          </code>
          character sets.
         </p>
        </li>
       </ul>
      </div>
      <p>
       <a class="link" href="server-status-variables.html#statvar_mecab_charset">
        <code class="literal">
         mecab_charset
        </code>
       </a>
       only
              reports the first supported character set. For example,
              the
       <code class="literal">
        ipadic_utf-8
       </code>
       dictionary supports
              both
       <code class="literal">
        utf8mb3
       </code>
       and
       <code class="literal">
        utf8mb4
       </code>
       .
       <a class="link" href="server-status-variables.html#statvar_mecab_charset">
        <code class="literal">
         mecab_charset
        </code>
       </a>
       always
              reports
       <code class="literal">
        utf8
       </code>
       when this dictionary is in
              use.
      </p>
     </div>
    </li>
    <li class="listitem">
     <p>
      Restart MySQL.
     </p>
    </li>
    <li class="listitem">
     <p>
      Install the MeCab parser plugin:
     </p>
     <p>
      The MeCab parser plugin is installed using
      <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
       <code class="literal">
        INSTALL PLUGIN
       </code>
      </a>
      . The plugin
            name is
      <code class="filename">
       mecab
      </code>
      , and the shared library
            name is
      <code class="filename">
       libpluginmecab.so
      </code>
      . For
            additional information about installing plugins, see
      <a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
       Section 7.6.1, “Installing and Uninstalling Plugins”
      </a>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa56789476"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> mecab <span class="token keyword">SONAME</span> <span class="token string">'libpluginmecab.so'</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Once installed, the MeCab parser plugin loads at every
            normal MySQL restart.
     </p>
    </li>
    <li class="listitem">
     <p>
      Verify that the MeCab parser plugin is loaded using the
      <a class="link" href="show-plugins.html" title="15.7.7.27 SHOW PLUGINS Statement">
       <code class="literal">
        SHOW PLUGINS
       </code>
      </a>
      statement.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa77780615"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">PLUGINS</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      A
      <code class="literal">
       mecab
      </code>
      plugin should appear in the list
            of plugins.
     </p>
    </li>
   </ol>
  </div>
  <h4>
   <a name="idm46045201115200">
   </a>
   Creating a FULLTEXT Index that uses the MeCab Parser
  </h4>
  <p>
   To create a
   <code class="literal">
    FULLTEXT
   </code>
   index that uses the
        mecab parser, specify
   <code class="literal">
    WITH PARSER ngram
   </code>
   with
   <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    <code class="literal">
     CREATE TABLE
    </code>
   </a>
   ,
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   , or
   <a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
    <code class="literal">
     CREATE INDEX
    </code>
   </a>
   .
  </p>
  <p>
   This example demonstrates creating a table with a
   <code class="literal">
    mecab
   </code>
   <code class="literal">
    FULLTEXT
   </code>
   index,
        inserting sample data, and viewing tokenized data in the
        Information Schema
   <a class="link" href="information-schema-innodb-ft-index-cache-table.html" title="28.4.18 The INFORMATION_SCHEMA INNODB_FT_INDEX_CACHE Table">
    <code class="literal">
     INNODB_FT_INDEX_CACHE
    </code>
   </a>
   table:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16584081"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> test<span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> articles <span class="token punctuation">(</span>
    id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
    title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    body <span class="token datatype">TEXT</span><span class="token punctuation">,</span>
    <span class="token keyword">FULLTEXT</span> <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> mecab
    <span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token keyword">NAMES</span> utf8mb4<span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> articles <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
    <span class="token punctuation">(</span><span class="token string">'データベース管理'</span><span class="token punctuation">,</span><span class="token string">'このチュートリアルでは、私はどのようにデータベースを管理する方法を紹介します'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">(</span><span class="token string">'データベースアプリケーション開発'</span><span class="token punctuation">,</span><span class="token string">'データベースアプリケーションを開発することを学ぶ'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> innodb_ft_aux_table<span class="token operator">=</span><span class="token string">"test/articles"</span><span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FT_INDEX_CACHE <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> doc_id<span class="token punctuation">,</span> position<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To add a
   <code class="literal">
    FULLTEXT
   </code>
   index to an existing table,
        you can use
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   or
   <a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
    <code class="literal">
     CREATE INDEX
    </code>
   </a>
   . For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85614482"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> articles <span class="token punctuation">(</span>
    id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
    title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    body <span class="token datatype">TEXT</span>
    <span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span>

<span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> articles <span class="token keyword">ADD</span> <span class="token keyword">FULLTEXT</span> <span class="token keyword">INDEX</span> ft_index <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> mecab<span class="token punctuation">;</span>

<span class="token comment" spellcheck="true"># Or:</span>

<span class="token keyword">CREATE</span> <span class="token keyword">FULLTEXT</span> <span class="token keyword">INDEX</span> ft_index <span class="token keyword">ON</span> articles <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> mecab<span class="token punctuation">;</span></code></pre>
  </div>
  <h4>
   <a name="idm46045201098160">
   </a>
   MeCab Parser Space Handling
  </h4>
  <p>
   The MeCab parser uses spaces as separators in query strings. For
        example, the MeCab parser tokenizes
   <span class="phrase" lang="ja">
    データベース管理
   </span>
   as
   <span class="phrase" lang="ja">
    データベース
   </span>
   and
   <span class="phrase" lang="ja">
    管理
   </span>
   .
  </p>
  <h4>
   <a name="idm46045201094832">
   </a>
   MeCab Parser Stopword Handling
  </h4>
  <p>
   By default, the MeCab parser uses the default stopword list,
        which contains a short list of English stopwords. For a stopword
        list applicable to Japanese, you must create your own. For
        information about creating stopword lists, see
   <a class="xref" href="fulltext-stopwords.html" title="14.9.4 Full-Text Stopwords">
    Section 14.9.4, “Full-Text Stopwords”
   </a>
   .
  </p>
  <h4>
   <a name="idm46045201092768">
   </a>
   MeCab Parser Term Search
  </h4>
  <p>
   For natural language mode search, the search term is converted
        to a union of tokens. For example,
   <span class="phrase" lang="ja">
    データベース管理
   </span>
   is converted
        to
   <span class="phrase" lang="ja">
    データベース 管理
   </span>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29048404"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> articles 
    <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'データベース管理'</span> <span class="token keyword">IN</span> <span class="token keyword">NATURAL</span> <span class="token keyword">LANGUAGE</span> <span class="token keyword">MODE</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   For boolean mode search, the search term is converted to a
        search phrase. For example,
   <span class="phrase" lang="ja">
    データベース管理
   </span>
   is converted
        to
   <span class="phrase" lang="ja">
    データベース 管理
   </span>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74483564"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> articles 
    <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'データベース管理'</span> <span class="token keyword">IN</span> <span class="token datatype">BOOLEAN</span> <span class="token keyword">MODE</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <h4>
   <a name="idm46045201085872">
   </a>
   MeCab Parser Wildcard Search
  </h4>
  <p>
   Wildcard search terms are not tokenized. A search on
   <span class="phrase" lang="ja">
    データベース管理*
   </span>
   is
        performed on the prefix,
   <span class="phrase" lang="ja">
    データベース管理
   </span>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4484606"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> articles 
    <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'データベース*'</span> <span class="token keyword">IN</span> <span class="token datatype">BOOLEAN</span> <span class="token keyword">MODE</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <h4>
   <a name="idm46045201082128">
   </a>
   MeCab Parser Phrase Search
  </h4>
  <p>
   Phrases are tokenized. For example,
   <span class="phrase" lang="ja">
    データベース管理
   </span>
   is tokenized
        as
   <span class="phrase" lang="ja">
    データベース 管理
   </span>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa97886042"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> articles 
    <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'"データベース管理"'</span> <span class="token keyword">IN</span> <span class="token datatype">BOOLEAN</span> <span class="token keyword">MODE</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <h4>
   <a name="install-mecab-binary">
   </a>
   Installing MeCab From a Binary Distribution (Optional)
  </h4>
  <p>
   This section describes how to install
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   from a binary distribution
        using a native package management utility. For example, on
        Fedora, you can use Yum to perform the installation:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa24883745"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">yum</span> mecab-devel</code></pre>
  </div>
  <p>
   On Debian or Ubuntu, you can perform an APT installation:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa91953721"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">apt-get</span> install mecab
<span class="token prompt">$&gt; </span><span class="token command">apt-get</span> install mecab-ipadic</code></pre>
  </div>
  <h4>
   <a name="build-mecab-from-source">
   </a>
   Installing MeCab From Source (Optional)
  </h4>
  <p>
   If you want to build
   <code class="filename">
    mecab
   </code>
   and
   <code class="filename">
    mecab-ipadic
   </code>
   from source, basic
        installation steps are provided below. For additional
        information, refer to the MeCab documentation.
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Download the tar.gz packages for
      <code class="filename">
       mecab
      </code>
      and
      <code class="filename">
       mecab-ipadic
      </code>
      from
      <a class="ulink" href="http://taku910.github.io/mecab/#download" target="_blank">
       http://taku910.github.io/mecab/#download
      </a>
      . As
            of February, 2016, the latest available packages are
      <code class="filename">
       mecab-0.996.tar.gz
      </code>
      and
      <code class="filename">
       mecab-ipadic-2.7.0-20070801.tar.gz
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Install
      <code class="filename">
       mecab
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa28450425"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">tar</span> zxfv mecab-0<span class="token punctuation">.</span>996<span class="token punctuation">.</span>tar
<span class="token prompt">$&gt; </span><span class="token command">cd</span> mecab-0<span class="token punctuation">.</span>996
<span class="token prompt">$&gt; </span><span class="token command">./configure</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span> check
<span class="token prompt">$&gt; </span><span class="token command">su</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span> install</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Install
      <code class="filename">
       mecab-ipadic
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa97614722"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">tar</span> zxfv mecab-ipadic-2<span class="token punctuation">.</span>7<span class="token punctuation">.</span>0-20070801<span class="token punctuation">.</span>tar
<span class="token prompt">$&gt; </span><span class="token command">cd</span> mecab-ipadic-2<span class="token punctuation">.</span>7<span class="token punctuation">.</span>0-20070801
<span class="token prompt">$&gt; </span><span class="token command">./configure</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span>
<span class="token prompt">$&gt; </span><span class="token command">su</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span> install</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Compile MySQL using the
      <a class="link" href="source-configuration-options.html#option_cmake_with_mecab">
       <code class="option">
        WITH_MECAB
       </code>
      </a>
      CMake option. Set
            the
      <a class="link" href="source-configuration-options.html#option_cmake_with_mecab">
       <code class="option">
        WITH_MECAB
       </code>
      </a>
      option to
      <code class="literal">
       system
      </code>
      if you have installed
      <code class="filename">
       mecab
      </code>
      and
      <code class="filename">
       mecab-ipadic
      </code>
      to the default location.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa69160808"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token constant">-DWITH_MECAB</span><span class="token attr-value"><span class="token punctuation">=</span>system</span></code></pre>
     </div>
     <p>
      If you defined a custom installation directory, set
      <a class="link" href="source-configuration-options.html#option_cmake_with_mecab">
       <code class="option">
        WITH_MECAB
       </code>
      </a>
      to the custom
            directory. For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa53886721"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token constant">-DWITH_MECAB</span><span class="token attr-value"><span class="token punctuation">=</span>/path/to/mecab</span></code></pre>
     </div>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
