<!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.3.2. Output format — 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.3. Command" href="../command.html" /> <link rel="next" title="8.3.3. Return code" href="return_code.html" /> <link rel="prev" title="8.3.1. コマンドバージョン" href="command_version.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/command/output_format.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="return_code.html" title="8.3.3. Return code" accesskey="N">next</a> |</li> <li class="right" > <a href="command_version.html" title="8.3.1. コマンドバージョン" accesskey="P">previous</a> |</li> <li><a href="../../index.html">groonga v3.0.5 documentation</a> »</li> <li><a href="../../reference.html" >8. リファレンスマニュアル</a> »</li> <li><a href="../command.html" accesskey="U">8.3. Command</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="output-format"> <h1>8.3.2. Output format<a class="headerlink" href="#output-format" title="Permalink to this headline">¶</a></h1> <div class="section" id="summary"> <h2>8.3.2.1. Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2> <p>Commands output their result as JSON, MessagePack, XML or TSV format.</p> <p>JSON and MessagePack output have the same structure. XML and TSV are their original structure.</p> <p>JSON or MessagePack is recommend format. XML is useful for visual result check. TSV is just for special use. Normally you doesn't need to use TSV.</p> </div> <div class="section" id="json-and-messagepack"> <h2>8.3.2.2. JSON and MessagePack<a class="headerlink" href="#json-and-messagepack" title="Permalink to this headline">¶</a></h2> <p>This secsion describes the structure of command result on JSON and MessagePack format. JSON is used to show structure because MessagePack is binary format. Binary format isn't proper for documenataion.</p> <p>JSON and MessagePack uses the following structure:</p> <div class="highlight-none"><div class="highlight"><pre>[HEADER, BODY] </pre></div> </div> <p>For example:</p> <div class="highlight-none"><div class="highlight"><pre>[ [ 0, 1337566253.89858, 0.000355720520019531 ], [ [ [ 1 ], [ [ "_id", "UInt32" ], [ "_key", "ShortText" ], [ "content", "Text" ], [ "n_likes", "UInt32" ] ], [ 2, "Groonga", "I started to use groonga. It's very fast!", 10 ] ] ] ] </pre></div> </div> <p>In the example, the following part is <tt class="docutils literal"><span class="pre">HEADER</span></tt>:</p> <div class="highlight-none"><div class="highlight"><pre>[ 0, 1337566253.89858, 0.000355720520019531 ] </pre></div> </div> <p>The following part is <tt class="docutils literal"><span class="pre">BODY</span></tt>:</p> <div class="highlight-none"><div class="highlight"><pre>[ [ [ 1 ], [ [ "_id", "UInt32" ], [ "_key", "ShortText" ], [ "content", "Text" ], [ "n_likes", "UInt32" ] ], [ 2, "Groonga", "I started to use groonga. It's very fast!", 10 ] ] ] </pre></div> </div> <div class="section" id="header"> <h3>8.3.2.2.1. <tt class="docutils literal"><span class="pre">HEADER</span></tt><a class="headerlink" href="#header" title="Permalink to this headline">¶</a></h3> <p><tt class="docutils literal"><span class="pre">HEADER</span></tt> is an array. The content of <tt class="docutils literal"><span class="pre">HEADER</span></tt> has some patterns.</p> <div class="section" id="success-case"> <h4>8.3.2.2.1.1. Success case<a class="headerlink" href="#success-case" title="Permalink to this headline">¶</a></h4> <p><tt class="docutils literal"><span class="pre">HEADER</span></tt> has three elements on success:</p> <div class="highlight-none"><div class="highlight"><pre>[0, UNIX_TIME_WHEN_COMMAND_IS_STARTED, ELAPSED_TIME] </pre></div> </div> <p>The first element is always <tt class="docutils literal"><span class="pre">0</span></tt>.</p> <p><tt class="docutils literal"><span class="pre">UNIX_TIME_WHEN_COMMAND_IS_STARTED</span></tt> is the number of seconds since 1970-01-01 00:00:00 UTC when the command is started processing. <tt class="docutils literal"><span class="pre">ELAPSED_TIME</span></tt> is the elapsed time for processing the command in seconds. Both <tt class="docutils literal"><span class="pre">UNIX_TIME_WHEN_COMMAND_IS_STARTED</span></tt> and <tt class="docutils literal"><span class="pre">ELAPSED_TIME</span></tt> are float value. The precision of them are nanosecond.</p> </div> <div class="section" id="error-case"> <h4>8.3.2.2.1.2. Error case<a class="headerlink" href="#error-case" title="Permalink to this headline">¶</a></h4> <p><tt class="docutils literal"><span class="pre">HEADER</span></tt> has four or five elements on error:</p> <div class="highlight-none"><div class="highlight"><pre>[ RETURN_CODE, UNIX_TIME_WHEN_COMMAND_IS_STARTED, ELAPSED_TIME, ERROR_MESSAGE, ERROR_LOCATION ] </pre></div> </div> <p><tt class="docutils literal"><span class="pre">ERROR_LOCATION</span></tt> may not be included in <tt class="docutils literal"><span class="pre">HEADER</span></tt> but other four elements are always included.</p> <p><tt class="docutils literal"><span class="pre">RETURN_CODE</span></tt> is non 0 value. See <a class="reference internal" href="return_code.html"><em>Return code</em></a> about available return codes.</p> <p><tt class="docutils literal"><span class="pre">UNIX_TIME_WHEN_COMMAND_IS_STARTED</span></tt> and <tt class="docutils literal"><span class="pre">ELAPSED_TIME</span></tt> are the same as success case.</p> <p><tt class="docutils literal"><span class="pre">ERROR_MESSAGE</span></tt> is an error message in string.</p> <p><tt class="docutils literal"><span class="pre">ERROR_LOCATION</span></tt> is optional. If error location is collected, <tt class="docutils literal"><span class="pre">ERROR_LOCATION</span></tt> is included. <tt class="docutils literal"><span class="pre">ERROR_LOCATION</span></tt> is an array. <tt class="docutils literal"><span class="pre">ERROR_LOCATION</span></tt> has one ore two elements:</p> <div class="highlight-none"><div class="highlight"><pre>[ LOCATION_IN_GROONGA, LOCATION_IN_INPUT ] </pre></div> </div> <p><tt class="docutils literal"><span class="pre">LOCATION_IN_GROONGA</span></tt> is the source location that error is occurred in groonga. It is useful for groonga developers but not useful for users. <tt class="docutils literal"><span class="pre">LOCATION_IN_GROONGA</span></tt> is an array. <tt class="docutils literal"><span class="pre">LOCATION_IN_GROONGA</span></tt> has three elements:</p> <div class="highlight-none"><div class="highlight"><pre>[ FUNCTION_NAME, SOURCE_FILE_NAME, LINE_NUMBER ] </pre></div> </div> <p><tt class="docutils literal"><span class="pre">FUNCTION_NAME</span></tt> is the name of function that error is occurred.</p> <p><tt class="docutils literal"><span class="pre">SOURCE_FILE_NAME</span></tt> is the name of groonga's source file that error is occurred.</p> <p><tt class="docutils literal"><span class="pre">LINE_NUMBER</span></tt> is the line number of <tt class="docutils literal"><span class="pre">SOURCE_FILE_NAME</span></tt> that error is occurred.</p> <p><tt class="docutils literal"><span class="pre">LOCATION_IN_INPUT</span></tt> is optional. <tt class="docutils literal"><span class="pre">LOCATION_IN_INPUT</span></tt> is included when the location that error is occurred in input file is collected. Input file can be specified by <tt class="docutils literal"><span class="pre">--file</span></tt> command line option for <tt class="docutils literal"><span class="pre">groonga</span></tt> command. <tt class="docutils literal"><span class="pre">LOCATION_IN_GROONGA</span></tt> is an array. <tt class="docutils literal"><span class="pre">LOCATION_IN_GROONGA</span></tt> has three elements:</p> <div class="highlight-none"><div class="highlight"><pre>[ INPUT_FILE_NAME, LINE_NUMBER, LINE_CONTENT ] </pre></div> </div> <p><tt class="docutils literal"><span class="pre">INPUT_FILE_NAME</span></tt> is the input file name that error is occurred.</p> <p><tt class="docutils literal"><span class="pre">LINE_NUMBER</span></tt> is the line number of <tt class="docutils literal"><span class="pre">INPUT_FILE_NAME</span></tt> that error is occurred.</p> <p><tt class="docutils literal"><span class="pre">LINE_CONTENT</span></tt> is the content at <tt class="docutils literal"><span class="pre">LINE_NUMBER</span></tt> in <tt class="docutils literal"><span class="pre">INPUT_FILE_NAME</span></tt>.</p> </div> </div> <div class="section" id="body"> <h3>8.3.2.2.2. <tt class="docutils literal"><span class="pre">BODY</span></tt><a class="headerlink" href="#body" title="Permalink to this headline">¶</a></h3> <p><tt class="docutils literal"><span class="pre">BODY</span></tt> content depends on the executed command. It may be omitted.</p> <p><tt class="docutils literal"><span class="pre">BODY</span></tt> may be an error message on error case.</p> </div> </div> <div class="section" id="xml"> <h2>8.3.2.3. XML<a class="headerlink" href="#xml" title="Permalink to this headline">¶</a></h2> <p>TODO</p> </div> <div class="section" id="tsv"> <h2>8.3.2.4. TSV<a class="headerlink" href="#tsv" title="Permalink to this headline">¶</a></h2> <p>TODO</p> </div> <div class="section" id="see-also"> <h2>8.3.2.5. See also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><a class="reference internal" href="return_code.html"><em>Return code</em></a> describes about return code.</li> </ul> </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.3.2. Output format</a><ul> <li><a class="reference internal" href="#summary">8.3.2.1. Summary</a></li> <li><a class="reference internal" href="#json-and-messagepack">8.3.2.2. JSON and MessagePack</a><ul> <li><a class="reference internal" href="#header">8.3.2.2.1. <tt class="docutils literal"><span class="pre">HEADER</span></tt></a><ul> <li><a class="reference internal" href="#success-case">8.3.2.2.1.1. Success case</a></li> <li><a class="reference internal" href="#error-case">8.3.2.2.1.2. Error case</a></li> </ul> </li> <li><a class="reference internal" href="#body">8.3.2.2.2. <tt class="docutils literal"><span class="pre">BODY</span></tt></a></li> </ul> </li> <li><a class="reference internal" href="#xml">8.3.2.3. XML</a></li> <li><a class="reference internal" href="#tsv">8.3.2.4. TSV</a></li> <li><a class="reference internal" href="#see-also">8.3.2.5. See also</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="command_version.html" title="previous chapter">8.3.1. コマンドバージョン</a></p> <h4>Next topic</h4> <p class="topless"><a href="return_code.html" title="next chapter">8.3.3. Return code</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/reference/command/output_format.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="return_code.html" title="8.3.3. Return code" >next</a> |</li> <li class="right" > <a href="command_version.html" title="8.3.1. コマンドバージョン" >previous</a> |</li> <li><a href="../../index.html">groonga v3.0.5 documentation</a> »</li> <li><a href="../../reference.html" >8. リファレンスマニュアル</a> »</li> <li><a href="../command.html" >8.3. Command</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Brazil, Inc. </div> </body> </html>