Debian Codegraph @

doc/source/reference/output.rst

raw
1 .. -*- rst -*-
2
3 Output
4 ======
5
6 Groonga supports the following output format types:
7
8 * `JSON <http://www.json.org/>`_
9 * `XML <http://www.w3.org/XML/>`_
10 * TSV (Tab Separated Values)
11 * `MessagePack <http://msgpack.org/>`_
12
13 JSON is the default output format.
14
15 Usage
16 -----
17
18 Groonga has the following query interfaces:
19
20 * command line
21 * HTTP
22
23 They provides different ways to change output format type.
24
25 Command line
26 ^^^^^^^^^^^^
27
28 You can use command line query interface by ``groonga
29 DB_PATH`` or ``groonga -c``. Those groonga commands shows
30 ``>`` prompt. In this query interface, you can specify
31 output format type by ``output_type`` option.
32
33 If you don't specify ``output_type`` option, you will get
34 a result in JSON format::
35
36 > status
37 [[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}]
38
39 You can specify ``json`` as ``output_type`` value to get a
40 result in JSON format explicitly::
41
42 > status --output_type json
43 [[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}]
44
45 You need to specify ``xml`` as ``output_type`` value to
46 get a result in XML format::
47
48 > status --output_type xml
49 <?xml version="1.0" encoding="utf-8"?>
50 <RESULT CODE="0" UP="1327721649.61095" ELAPSED="0.000126361846923828">
51 <RESULT>
52 <TEXT>alloc_count</TEXT>
53 <INT>146</INT>
54 <TEXT>starttime</TEXT>
55 <INT>1327721626</INT>
56 <TEXT>uptime</TEXT>
57 <INT>23</INT>
58 <TEXT>version</TEXT>
59 <TEXT>1.2.9-92-gb87d9f8</TEXT>
60 <TEXT>n_queries</TEXT>
61 <INT>0</INT>
62 <TEXT>cache_hit_rate</TEXT>
63 <FLOAT>0.0</FLOAT>
64 <TEXT>command_version</TEXT>
65 <INT>1</INT>
66 <TEXT>default_command_version</TEXT>
67 <INT>1</INT>
68 <TEXT>max_command_version</TEXT>
69 <INT>2</INT></RESULT>
70 </RESULT>
71
72 You need to specify ``tsv`` as ``output_type`` value to
73 get a result in TSV format::
74
75 > status --output_type tsv
76 0 1327721664.82675 0.000113964080810547
77 "alloc_count" 146
78 "starttime" 1327721626
79 "uptime" 38
80 "version" "1.2.9-92-gb87d9f8"
81 "n_queries" 0
82 "cache_hit_rate" 0.0
83 "command_version" 1
84 "default_command_version" 1
85 "max_command_version" 2
86 END
87
88
89 You need to specify ``msgpack`` as ``output_type`` value to
90 get a result in MessagePack format::
91
92 > status --output_type msgpack
93 (... omitted because MessagePack is binary data format. ...)
94
95 HTTP
96 ^^^^
97
98 You can use HTTP query interface by ``groonga --protocol
99 http -s DB_PATH``. Groonga HTTP server starts on port 10041
100 by default. In this query interface, you can specify
101 output format type by extension.
102
103 If you don't specify extension, you will get a result in
104 JSON format::
105
106 % curl http://localhost:10041/d/status
107 [[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}]
108
109 You can specify ``json`` as extension to get a result in
110 JSON format explicitly::
111
112 % curl http://localhost:10041/d/status.json
113 [[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}]
114
115 You need to specify ``xml`` as extension to get a result in
116 XML format::
117
118 % curl http://localhost:10041/d/status.xml
119 <?xml version="1.0" encoding="utf-8"?>
120 <RESULT CODE="0" UP="1327809339.5782" ELAPSED="9.56058502197266e-05">
121 <RESULT>
122 <TEXT>alloc_count</TEXT>
123 <INT>159</INT>
124 <TEXT>starttime</TEXT>
125 <INT>1327809282</INT>
126 <TEXT>uptime</TEXT>
127 <INT>57</INT>
128 <TEXT>version</TEXT>
129 <TEXT>1.2.9-92-gb87d9f8</TEXT>
130 <TEXT>n_queries</TEXT>
131 <INT>0</INT>
132 <TEXT>cache_hit_rate</TEXT>
133 <FLOAT>0.0</FLOAT>
134 <TEXT>command_version</TEXT>
135 <INT>1</INT>
136 <TEXT>default_command_version</TEXT>
137 <INT>1</INT>
138 <TEXT>max_command_version</TEXT>
139 <INT>2</INT></RESULT>
140 </RESULT>
141
142 You need to specify ``tsv`` as extension to get a result in
143 TSV format::
144
145 % curl http://localhost:10041/d/status.tsv
146 0 1327809366.84187 8.44001770019531e-05
147 "alloc_count" 159
148 "starttime" 1327809282
149 "uptime" 84
150 "version" "1.2.9-92-gb87d9f8"
151 "n_queries" 0
152 "cache_hit_rate" 0.0
153 "command_version" 1
154 "default_command_version" 1
155 "max_command_version" 2
156 END
157
158 You need to specify ``msgpack`` as extension to get a result
159 in MessagePack format::
160
161 % curl http://localhost:10041/d/status.msgpack
162 (... omitted because MessagePack is binary data format. ...)