<!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.2. 出力 — 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="8. リファレンスマニュアル" href="../reference.html" /> <link rel="next" title="8.3. コマンド" href="command.html" /> <link rel="prev" title="8.1.6. groonga-suggest-create-dataset" href="executables/groonga-suggest-create-dataset.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/reference/output.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="command.html" title="8.3. コマンド" accesskey="N">次へ</a> |</li> <li class="right" > <a href="executables/groonga-suggest-create-dataset.html" title="8.1.6. groonga-suggest-create-dataset" accesskey="P">前へ</a> |</li> <li><a href="../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../reference.html" accesskey="U">8. リファレンスマニュアル</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="output"> <h1>8.2. 出力<a class="headerlink" href="#output" title="このヘッドラインへのパーマリンク">¶</a></h1> <p>groongaは以下の出力形式をサポートしています。</p> <blockquote> <div><ul class="simple"> <li><p class="first"><a class="reference external" href="http://www.json.org/json-ja.html">JSON</a></p> </li> <li><a class="reference external" href="http://www.w3.org/XML/">XML</a></li> <li><p class="first">TSV(タブ区切り形式)</p> </li> <li><a class="reference external" href="http://msgpack.org/">MessagePack</a></li> </ul> </div></blockquote> <p>JSONがデフォルトの出力形式です。</p> <div class="section" id="usage"> <h2>8.2.1. 使い方<a class="headerlink" href="#usage" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>groongaには以下のクエリーインターフェイスがあります。</p> <blockquote> <div><ul class="simple"> <li><p class="first">コマンドライン</p> </li> <li>HTTP</li> </ul> </div></blockquote> <p>それぞれのインターフェイスで出力形式を変更する方法は異なります。</p> <div class="section" id="command-line"> <h3>8.2.1.1. コマンドライン<a class="headerlink" href="#command-line" title="このヘッドラインへのパーマリンク">¶</a></h3> <p><tt class="docutils literal"><span class="pre">groonga</span> <span class="pre">DB_PATH</span></tt> または <tt class="docutils literal"><span class="pre">groonga</span> <span class="pre">-c</span></tt> でコマンドラインクエリーインターフェイスを使うことができます。これらのgroongaコマンドでは <tt class="docutils literal"><span class="pre">></span> <span class="pre">``</span> <span class="pre">というプロンプトが表示されます。クエリーインターフェイスでは</span> <span class="pre">``output_type</span></tt> オプションで出力形式を指定できます。</p> <p><tt class="docutils literal"><span class="pre">output_type</span></tt> オプションを指定しない場合はJSON形式の出力になります:</p> <div class="highlight-none"><div class="highlight"><pre>> status [[0,1327721628.10738,0.000131845474243164],{"alloc_count":142,"starttime":1327721626,"uptime":2,"version":"1.2.9-92-gb87d9f8","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}] </pre></div> </div> <p>明示的に <tt class="docutils literal"><span class="pre">output_type</span></tt> に <tt class="docutils literal"><span class="pre">json</span></tt> を指定することもできます。この場合はJSON形式の出力になります:</p> <div class="highlight-none"><div class="highlight"><pre>> status --output_type json [[0,1327721639.08321,7.93933868408203e-05],{"alloc_count":144,"starttime":1327721626,"uptime":13,"version":"1.2.9-92-gb87d9f8","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}] </pre></div> </div> <p>XML形式の出力にする場合は <tt class="docutils literal"><span class="pre">output_type</span></tt> に <tt class="docutils literal"><span class="pre">xml</span></tt> を指定します:</p> <div class="highlight-none"><div class="highlight"><pre>> status --output_type xml <?xml version="1.0" encoding="utf-8"?> <RESULT CODE="0" UP="1327721649.61095" ELAPSED="0.000126361846923828"> <RESULT> <TEXT>alloc_count</TEXT> <INT>146</INT> <TEXT>starttime</TEXT> <INT>1327721626</INT> <TEXT>uptime</TEXT> <INT>23</INT> <TEXT>version</TEXT> <TEXT>1.2.9-92-gb87d9f8</TEXT> <TEXT>n_queries</TEXT> <INT>0</INT> <TEXT>cache_hit_rate</TEXT> <FLOAT>0.0</FLOAT> <TEXT>command_version</TEXT> <INT>1</INT> <TEXT>default_command_version</TEXT> <INT>1</INT> <TEXT>max_command_version</TEXT> <INT>2</INT></RESULT> </RESULT> </pre></div> </div> <p>TSV形式の出力にする場合は <tt class="docutils literal"><span class="pre">output_type</span></tt> に <tt class="docutils literal"><span class="pre">tsv</span></tt> を指定します::<</p> <div class="highlight-none"><div class="highlight"><pre>> status --output_type tsv 0 1327721664.82675 0.000113964080810547 "alloc_count" 146 "starttime" 1327721626 "uptime" 38 "version" "1.2.9-92-gb87d9f8" "n_queries" 0 "cache_hit_rate" 0.0 "command_version" 1 "default_command_version" 1 "max_command_version" 2 END </pre></div> </div> <p>MessagePack形式の出力にする場合は <tt class="docutils literal"><span class="pre">output_type</span></tt> に <tt class="docutils literal"><span class="pre">msgpack</span></tt> を指定します::<</p> <div class="highlight-none"><div class="highlight"><pre>> status --output_type msgpack (... omitted because MessagePack is binary data format. ...) </pre></div> </div> </div> <div class="section" id="http"> <h3>8.2.1.2. HTTP<a class="headerlink" href="#http" title="このヘッドラインへのパーマリンク">¶</a></h3> <p><tt class="docutils literal"><span class="pre">groonga</span> <span class="pre">--protocol</span> <span class="pre">http</span> <span class="pre">-s</span> <span class="pre">DB_PATH</span></tt> でHTTPクエリーインターフェイスを使うことができます。groonga HTTPサーバーはデフォルトで10041番ポートで起動します。このクエリーインターフェイスでは拡張子で出力形式を指定します。</p> <p>拡張子を指定しない場合はJSON形式の出力になります:</p> <div class="highlight-none"><div class="highlight"><pre>% curl http://localhost:10041/d/status [[0,1327809294.54311,0.00082087516784668],{"alloc_count":155,"starttime":1327809282,"uptime":12,"version":"1.2.9-92-gb87d9f8","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}] </pre></div> </div> <p>明示的に <tt class="docutils literal"><span class="pre">json</span></tt> 拡張子を指定することもできます。この場合はJSON形式の出力になります:</p> <div class="highlight-none"><div class="highlight"><pre>% curl http://localhost:10041/d/status.json [[0,1327809319.01929,9.5367431640625e-05],{"alloc_count":157,"starttime":1327809282,"uptime":37,"version":"1.2.9-92-gb87d9f8","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}] </pre></div> </div> <p>XML形式の出力にする場合は <tt class="docutils literal"><span class="pre">xml</span></tt> 拡張子を指定します:</p> <div class="highlight-none"><div class="highlight"><pre>% curl http://localhost:10041/d/status.xml <?xml version="1.0" encoding="utf-8"?> <RESULT CODE="0" UP="1327809339.5782" ELAPSED="9.56058502197266e-05"> <RESULT> <TEXT>alloc_count</TEXT> <INT>159</INT> <TEXT>starttime</TEXT> <INT>1327809282</INT> <TEXT>uptime</TEXT> <INT>57</INT> <TEXT>version</TEXT> <TEXT>1.2.9-92-gb87d9f8</TEXT> <TEXT>n_queries</TEXT> <INT>0</INT> <TEXT>cache_hit_rate</TEXT> <FLOAT>0.0</FLOAT> <TEXT>command_version</TEXT> <INT>1</INT> <TEXT>default_command_version</TEXT> <INT>1</INT> <TEXT>max_command_version</TEXT> <INT>2</INT></RESULT> </RESULT> </pre></div> </div> <p>TSV形式の出力にする場合は <tt class="docutils literal"><span class="pre">tsv</span></tt> 拡張子を指定します:</p> <div class="highlight-none"><div class="highlight"><pre>% curl http://localhost:10041/d/status.tsv 0 1327809366.84187 8.44001770019531e-05 "alloc_count" 159 "starttime" 1327809282 "uptime" 84 "version" "1.2.9-92-gb87d9f8" "n_queries" 0 "cache_hit_rate" 0.0 "command_version" 1 "default_command_version" 1 "max_command_version" 2 END </pre></div> </div> <p>MessagePack形式の出力にする場合は <tt class="docutils literal"><span class="pre">msgpack</span></tt> 拡張子を指定します:</p> <div class="highlight-none"><div class="highlight"><pre>% curl http://localhost:10041/d/status.msgpack (... omitted because MessagePack is binary data format. ...) </pre></div> </div> </div> </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="#">8.2. 出力</a><ul> <li><a class="reference internal" href="#usage">8.2.1. 使い方</a><ul> <li><a class="reference internal" href="#command-line">8.2.1.1. コマンドライン</a></li> <li><a class="reference internal" href="#http">8.2.1.2. HTTP</a></li> </ul> </li> </ul> </li> </ul> <h4>前のトピックへ</h4> <p class="topless"><a href="executables/groonga-suggest-create-dataset.html" title="前の章へ">8.1.6. groonga-suggest-create-dataset</a></p> <h4>次のトピックへ</h4> <p class="topless"><a href="command.html" title="次の章へ">8.3. コマンド</a></p> <h3>このページ</h3> <ul class="this-page-menu"> <li><a href="../_sources/reference/output.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="command.html" title="8.3. コマンド" >次へ</a> |</li> <li class="right" > <a href="executables/groonga-suggest-create-dataset.html" title="8.1.6. groonga-suggest-create-dataset" >前へ</a> |</li> <li><a href="../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../reference.html" >8. リファレンスマニュアル</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Brazil, Inc. </div> </body> </html>