File: output.rst

package info (click to toggle)
groonga 15.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 163,080 kB
  • sloc: ansic: 770,564; cpp: 48,925; ruby: 40,447; javascript: 10,250; yacc: 7,045; sh: 5,602; python: 2,821; makefile: 1,672
file content (162 lines) | stat: -rw-r--r-- 4,806 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.. -*- rst -*-

Output
======

Groonga supports the following output format types:

  * `JSON <http://www.json.org/>`_
  * `XML <http://www.w3.org/XML/>`_
  * TSV (Tab Separated Values)
  * `MessagePack <http://msgpack.org/>`_

JSON is the default output format.

Usage
-----

Groonga has the following query interfaces:

  * command line
  * HTTP

They provides different ways to change output format type.

Command line
^^^^^^^^^^^^

You can use command line query interface by ``groonga
DB_PATH`` or ``groonga -c``. Those groonga commands shows
``>`` prompt. In this query interface, you can specify
output format type by ``output_type`` option.

If you don't specify ``output_type`` option, you will get
a result in JSON format::

  > 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}]

You can specify ``json`` as ``output_type`` value to get a
result in JSON format explicitly::

  > 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}]

You need to specify ``xml`` as ``output_type`` value to
get a result in XML format::

  > 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>

You need to specify ``tsv`` as ``output_type`` value to
get a result in TSV format::

  > 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


You need to specify ``msgpack`` as ``output_type`` value to
get a result in MessagePack format::

  > status --output_type msgpack
  (... omitted because MessagePack is binary data format. ...)

HTTP
^^^^

You can use HTTP query interface by ``groonga --protocol
http -s DB_PATH``. Groonga HTTP server starts on port 10041
by default. In this query interface, you can specify
output format type by extension.

If you don't specify extension, you will get a result in
JSON format::

  % 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}]

You can specify ``json`` as extension to get a result in
JSON format explicitly::

  % 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}]

You need to specify ``xml`` as extension to get a result in
XML format::

  % 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>

You need to specify ``tsv`` as extension to get a result in
TSV format::

  % 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

You need to specify ``msgpack`` as extension to get a result
in MessagePack format::

  % curl http://localhost:10041/d/status.msgpack
  (... omitted because MessagePack is binary data format. ...)