/[hyperestraier]/trunk/doc/nguide-en.html
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/doc/nguide-en.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Fri Jul 29 21:57:20 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/html
File size: 55479 byte(s)
make working copy from version 0.5.1

1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
7 <head>
8 <meta http-equiv="Content-Language" content="en" />
9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
10 <meta http-equiv="Content-Style-Type" content="text/css" />
11 <meta name="author" content="Mikio Hirabayashi" />
12 <meta name="keywords" content="Hyper Estraier, Estraier, full-text search, API, Node, P2P" />
13 <meta name="description" content="API specifications of Hyper Estraier" />
14 <link rel="contents" href="./" />
15 <link rel="alternate" href="nguide-ja.html" hreflang="ja" title="the Japanese version" />
16 <link rel="stylesheet" href="common.css" />
17 <link rel="icon" href="icon16.png" />
18 <link rev="made" href="mailto:mikio@users.sourceforge.net" />
19 <title>P2P Guide of Hyper Estraier Version 1</title>
20 </head>
21
22 <body>
23
24 <h1>P2P Guide</h1>
25
26 <div class="note">Copyright (C) 2004-2005 Mikio Hirabayashi</div>
27 <div class="note">Last Update: Tue, 07 Jun 2005 06:17:00 +0900</div>
28 <div class="navi">[<a href="nguide-ja.html" hreflang="ja">Japanese</a>] [<a href="index.html">HOME</a>]</div>
29
30 <hr />
31
32 <h2 id="tableofcontents">Table of Contents</h2>
33
34 <ol>
35 <li><a href="#introduction">Introduction</a></li>
36 <li><a href="#architecture">Architecture</a></li>
37 <li><a href="#tutorial">Tutorial</a></li>
38 <li><a href="#estmaster">Command of the Node Master</a></li>
39 <li><a href="#protocol">Protocol</a></li>
40 <li><a href="#nodeapi">Node API</a></li>
41 <li><a href="#estcall">Command of a Client</a></li>
42 </ol>
43
44 <hr />
45
46 <h2 id="introduction">Introduction</h2>
47
48 <p>This document describes how to use P2P mechanism of Hyper Estraier. If you have never read <a href="uguide-en.html">the user's guide</a>, please read it beforehand.</p>
49
50 <p>estseek.cgi is not efficient because it connects to the database per execution. And, it is impossible to perform search during database updating, because estcmd locks the database. To solve the problem, Hyper Estraier provides a server program of C/S (client/server) architecture. There are a resident process keeping connection to the database and it serves some operations via network. The C/S architecture has the following advantages.</p>
51
52 <ul>
53 <li>The server and its clients work on separate machines.</li>
54 <li>Plural clients of one server can work in parallel.</li>
55 <li>The database is not broken even when some clients crush.</li>
56 <li>Clients can be implemented without dependency of programming languages or APIs.</li>
57 </ul>
58
59 <p>Because the protocol between C/S is based on HTTP, some popular web browsers can be used as clients. Of course, clients can be implemented on your own way. It is also good idea to use such technologies around web browser as JavaScript, Flash, and so on.</p>
60
61 <p>Distributed processing based on P2P (Peer to Peer) architecture is supported. If you use 10 servers handling one million of documents, you can search 10 millions of documents. Because servers are equivalent, whole of the network service works successively even if a server crushes. Moreover, calculating reliability between servers is supported and it can improve search precision.</p>
62
63 <p>The node API is provided to hide the protocol between C/S. Using the node API, you can implement client applications without closeup know-hows about network. This document describes how to use the node API also.</p>
64
65 <hr />
66
67 <h2 id="architecture">Architecture</h2>
68
69 <p>This section describes the P2P arhcitecture of Hyper Estraier.</p>
70
71 <h3>Node Master and Node Server</h3>
72
73 <p>If you uses many indexes, it is inefficient to run a server per index. So, a program called node master is provided. While it works as one process and uses one network port, it can handle several indexes. Because each index performs its own service, we can regard a "node master" as aggregation of several index servers. On the viewpoint, each virtual server handling an index is called "node server". Each node server has an own URL. A client application knows URL of a node server but does not know in which node master the node server works.</p>
74
75 <div class="illust"><img src="nodeframe.png" width="720" height="350" alt="[framework]" /></div>
76
77 <p>The term "node" is used as with the term "peer" in the P2P architecture. As a client connects to a node master itself and manage some nodes, another client connects to a node server and search/register docments.</p>
78
79 <h3>Meta Search and Credit</h3>
80
81 <p>A node server can link to another node server one-sidedly. When a client send a query to a node server, the node server relay the query to linked nodes. Responses of linked nodes and the first node are merged and sent back to the client. That is, so-called meta search is supported by every nodes and it realizes destributed processing in P2P architecture.</p>
82
83 <p>The meta search is performed hierarchically. Because loop of routing is detected and restrained automatically, the behavior is as with search of tree structured network. Due to this mechanism, it is possible to increase nodes of the network up to infinity.</p>
84
85 <div class="illust"><img src="metatree.png" width="720" height="400" alt="[tree of meta search]" /></div>
86
87 <p>Reliability called "credit" is set to each link between nodes. When a node merges responses collected by meta search, credit is used for weighting of scores. So, documents in response of nodes with high credit is apt to be shown in high ranks. As applications are responsible to set links and their credit, it is possible to improve search precision by increasing credit of frequently used nodes.</p>
88
89 <h3>Authentication</h3>
90
91 <p>When a client connects to the node master or a node server, authentication with a user name and a password is performed. Users are classified into super users and normal users. The former has permission to manage nodes and users. The latter does not have those permissions. Moreover, permission is granted for each node servers. Each node has lists of administrator who can update the index and normal users who can perform search only. Besides, super users of the node master can connect as administrators to node servers in the same node master.</p>
92
93 <hr />
94
95 <h2 id="tutorial">Tutorial</h2>
96
97 <p>As the concept of P2P seems difficult, let's try to use some commands and learn it by degrees.</p>
98
99 <h3>Start and Stop</h3>
100
101 <p>For preparation for the node master, create the server root directory which includes configuration files and indexes. Perform the following command and a directory "casket" will be created.</p>
102
103 <pre>estmaster init casket
104 </pre>
105
106 <p>Next, start the node master. Perform the following command.</p>
107
108 <pre>estmaster start casket
109 </pre>
110
111 <p>To stop the node master, input Ctrl-D on the terminal on which the node master is running or perform the following command on another terminal.</p>
112
113 <pre>estmaster stop casket
114 </pre>
115
116 <h3>Administration Interface</h3>
117
118 <p>While the node master is running, we can access "http://localhost:1978/masterui" with a web browser and use the adminisration interface. When access the URL, a dialog is shown and the user name and the password is required. Input "admin" and "admin". Then, the menu of administration commands is displayed.</p>
119
120 <p>If you step into "Manage Master" and select "SHUTDOWN", you can stop the node master. But, leave it for now.</p>
121
122 <p>Select "Manage Users". As you have logged in as a user whose name is "admin", create a new user account and switch to it. Input the user name, the password, the flags, the full name, and the the miscellaneous information into the forms at the bottom of the page. The name and the password can contain alphanumeric characters only. As for now, input "clint", "tnilc", "s", "Clint Eastwood", and "Dirty Harry". It is important to set "s" in the flags. It means that the user is a super user.</p>
123
124 <p>Now, the user "admin" is no longer in use. As it has some potential security problems, delete it. Select the "DELE" in the line of "admin" and push "delete" on the next confirmation step.</p>
125
126 <p>Step into "Manage Nodes". Because the user "admin" is deleted, you are asked the user name and the password again. Input the "clint" and "tnilc" so that you can continue. In turn, create new nodes. Input the node name and the label into the form at the bottom of the page. The name can contain alphanumeric characters only. As for now, create a node whose name is "test1" and whose label is "First Node". And create another node whose name is "test2" and whose label is "Second Node".</p>
127
128 <h3>Register Documents</h3>
129
130 <p>Back to the command line operations. As the terminal of the node master is busy to show log messages, open another terminal.</p>
131
132 <p>Let's register some documents into the indexes of nodes. It is needed to prapare document draft data of documents to register. Create the following file and save it as "data001.est".</p>
133
134 <pre>@uri=data001
135 @title=Material Girl
136
137 Living in a material world
138 And I am a material girl
139 You know that we are living in a material world
140 And I am a material girl
141 </pre>
142
143 <p>To register it into the node "test1", perform the following command. Because the permission as administrators is needed to update the index, you should specify the user name and the password with the -auth option. Process of registration finishes in a flash. It is success if no error message is shown.</p>
144
145 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test1 data001.est
146 </pre>
147
148 <p>For explanation of meta search said later, register another document into the node "test2" also. Create the following file and save it as "data002.est".</p>
149
150 <pre>@uri=data002
151 @title=Liberian Girl
152
153 Liberian girl
154 You came and you changed My world
155 A love so brand new
156 </pre>
157
158 <p>Then, perform the following command.</p>
159
160 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test2 data002.est
161 </pre>
162
163 <p>It is useful to register documents from remote machines, isn't it? As with the above steps, register some other documents.</p>
164
165 <h3>Search for Documents</h3>
166
167 <p>All right, let's search for some registered documents. Perform the following command, and information of the corresponding document is shown.</p>
168
169 <pre>estcall search http://localhost:1978/node/test1 "material world"
170 </pre>
171
172 <p>By setting a link between the two nodes, you can do meta search. Now, set the link from "test1" to "test2". Specify the URL of the source node, the URL of the destination node, the label to display, and the credit.</p>
173
174 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
175 http://localhost:1978/node/test2 TEST02 8000
176 </pre>
177
178 <p>And, search again. This time, set depth of meta search with the option -dpt.</p>
179
180 <pre>estcall search -dpt 1 http://localhost:1978/node/test1 "girl"
181 </pre>
182
183 <p>Though you access the node "test1", the result of "test2" is merged and shown. It is the feature of meta search in P2P architecture. If "test1" and "test2" are on separate machines, distributed computing is realized.</p>
184
185 <p>By increasing the credit, ranking of documents in the result of the destination node is to be higher. Perform the following command and search again. Then, you will see the ranking is changed.</p>
186
187 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
188 http://localhost:1978/node/test2 TEST02 12000
189 </pre>
190
191 <p>You can get result as XML data. Perform the following command. See estresult.dtd for detail of the XML format.</p>
192
193 <pre>estcall search -dpt 1 -vx http://localhost:1978/node/test1 "girl"
194 </pre>
195
196 <p>Each node server embeds search interface for web browsers. Access "http://localhost:1978/node/test1/searchui" to use it.</p>
197
198 <hr />
199
200 <h2 id="estmaster">Command of the Node Master</h2>
201
202 <p>`estmaster' is provided as a command to manage the node master. This section describes how to use estmaster.</p>
203
204 <h3>Synopsis and Description</h3>
205
206 <p>estmaster is an aggregation of sub commands. The name of a sub command is specified by the first argument. Other arguments are parsed according to each sub command. The argument <var>rootdir</var> specifies the server root directory which contains configuration file and so on.</p>
207
208 <dl>
209 <dt><kbd>estmaster init [-ex] <var>rootdir</var></kbd></dt>
210 <dd>Create the server root directory.</dd>
211 <dd>If -ex is specified, some users and some nodes are set for example. By default, only a super user whose name and password are both "admin" is set.</dd>
212 </dl>
213
214 <dl>
215 <dt><kbd>estmaster start [-bg] [-st] <var>rootdir</var></kbd></dt>
216 <dd>Start the node master.</dd>
217 <dd>If -bg is specified, the server runs in background as a daemon process.</dd>
218 <dd>If -st is specified, the server runs in single thread mode.</dd>
219 </dl>
220
221 <dl>
222 <dt><kbd>estmaster stop <var>rootdir</var></kbd></dt>
223 <dd>Stop the running node master.</dd>
224 </dl>
225
226 <dl>
227 <dt><kbd>estmaster unittest <var>rootdir</var></kbd></dt>
228 <dd>Perform unit tests.</dd>
229 </dl>
230
231 <dl>
232 <dt><kbd>estmaster crypt <var>key</var> [<var>hash</var>]</kbd></dt>
233 <dd>Output an encrypted string of a string.</dd>
234 <dd><var>key</var> specifies a target string.</dd>
235 <dd>If <var>hash</var> is specified, it checks whether the key and the hash matches.</dd>
236 </dl>
237
238 <p>All sub commands return 0 if the operation is success, else return 1. A running node master finishs with closing the database when it catchs the signal 2 (SIGINT), 3 (SIGQUIT), or 15 (SIGTERM). Moreover, when a running node master catches the signal 1 (SIGHUP), the process is re-start and re-read the configuration files.</p>
239
240 <p>A running node server sould be finished by valid means by command line or via network. Otherwise, the index may be broken.</p>
241
242 <h3>Constitution of the Server Root Directory</h3>
243
244 <p>The server root directory contains the following files and directories.</p>
245
246 <ul>
247 <li><kbd>_conf</kbd> : prime configuration file.</li>
248 <li><kbd>_user</kbd> : user account file.</li>
249 <li><kbd>_log</kbd> : log file.</li>
250 <li><kbd>_meta</kbd> : database file for meta data.</li>
251 <li><kbd>_pid</kbd> : file recording the process ID.</li>
252 <li><kbd>_stop</kbd> : file to stop the node master.</li>
253 <li><kbd>_node/</kbd> : node directory.</li>
254 <li><kbd>_sess/</kbd> : session directory.</li>
255 </ul>
256
257 <p>The prime configuration file can be edit with a text editor. However, the user account file should not be edit during the node master is running.</p>
258
259 <p>If you have an index created by estcmd, move it into the node directory and reboot the server. So, the index will work as a node.</p>
260
261 <h3>Prime Configuration File</h3>
262
263 <p>The prime configuration file is composed of lines and the name of an variable and the value separated by `:' are in each line. By default, the following configuration is there.</p>
264
265 <pre>hostname: localhost
266 portnum: 1978
267 runmode: 1
268 authmode: 2
269 maxconn: 30
270 sessiontimeout: 600
271 searchtimeout: 8
272 searchdepth: 5
273 proxyhost:
274 proxyport:
275 loglevel: 2
276 docroot:
277 indexfile:
278 trustednodes:
279 denyuntrusted: 0
280 cachesize: 64
281 specialcache:
282 snipwwidth: 480
283 sniphwidth: 96
284 snipawidth: 96
285 </pre>
286
287 <p>Means of each variable is the following.</p>
288
289 <ul>
290 <li><kbd>hostname</kbd> : specifies the host name of the server.</li>
291 <li><kbd>portnum</kbd> : specifies the port number of the server.</li>
292 <li><kbd>runmode</kbd> : specifies running mode (1:normal, 2:readonly).</li>
293 <li><kbd>authmode</kbd> : specifies authorization mode (1:none, 2:admin, 3:all).</li>
294 <li><kbd>maxconn</kbd> : specifies maximum number of connections at the same time.</li>
295 <li><kbd>sessiontimeout</kbd> : specifies timeout of a session (in seconds).</li>
296 <li><kbd>searchtimeout</kbd> : specifies timeout of search (in seconds).</li>
297 <li><kbd>searchdepth</kbd> : specifies maximum depth of meta search.</li>
298 <li><kbd>proxyhost</kbd> : specifies the host name of the proxy server.</li>
299 <li><kbd>proxyport</kbd> : specifies the port number of the proxy server.</li>
300 <li><kbd>loglevel</kbd> : specifies logging level (1:debug, 2:information, 3:warning, 4:error, 5:none).</li>
301 <li><kbd>docroot</kbd> : specifies document root directory (full path of a directory to be public).</li>
302 <li><kbd>indexfile</kbd> : specifies index file (name of directory index files).</li>
303 <li><kbd>trustednodes</kbd> : specifies decimal IP addresses of trusted nodes (list separated by comma).</li>
304 <li><kbd>denyuntrusted</kbd> : specifies whether to deny all nodes except for trusted nodes (0:no, 1:yes).</li>
305 <li><kbd>cachesize</kbd> : specifies maximum size of the index cache (in mega bytes).</li>
306 <li><kbd>specialcache</kbd> : specifies name of the attribute of the special cache.</li>
307 <li><kbd>snipwwidth</kbd> : specifies whole width of the snippet of each shown document.</li>
308 <li><kbd>sniphwidth</kbd> : specifies width of strings picked up from the beginning of the text.</li>
309 <li><kbd>snipawidth</kbd> : specifies width of strings picked up around each highlighted word.</li>
310 </ul>
311
312 <h3>User Account File</h3>
313
314 <p>The user account file is composed of lines and each includes the name, the encrypted password, the flags, the full name, and the miscellaneous information separated by tabs. The character encoding is UTF-8. By default, the following account is there.</p>
315
316 <pre>admin 21232f297a57a5a743894a0e4a801fc3 s Carolus Magnus Administrator
317 </pre>
318
319 <p>The password is expressed as MD5 hash value. In the flags, "s" is for super users, and "b" is for banned users. Flags, full name, and miscellaneous information can be omitted.</p>
320
321 <h3>Embedded User Interfaces</h3>
322
323 <p>By accessing the absolute URL "/masterui" of the node master with a web browser, you can use the administration interface. It requires authentication as a super user.</p>
324
325 <p>By accessing the URL which is the URL of a node server followed by "/searchui", you can use the search interface.</p>
326
327 <hr />
328
329 <h2 id="protocol">Protocol</h2>
330
331 <p>Communication between nodes and communication between clients and nodes are carried out by a protocol based on HTTP. This section describes the protocol.</p>
332
333 <h3>Introduction</h3>
334
335 <p>The node master and node servers implement HTTP/1.0. As for now, such particular features of HTTP/1.1 as keep-alive connection, chunked encoding, and content negotiation are not supported.</p>
336
337 <p>While both of GET and POST are allowed for the request method of HTTP, GET is preferred if the command retrieves information, POST is preferred if the command update the node master or a node server. As the character encoding of parameters is UTF-8, meta characters and multi-byte characters should be escaped by URL encoding (application/x-www-form-urlencoded). The maximum length of data sent with the GET method is 8000. Authority information is passed in the basic authentication mechanism of HTTP.</p>
338
339 <p>If an operation is done successfully, the status code 200 or 202 is returned. On error, one of the following status code is returned.</p>
340
341 <ul>
342 <li>400 : parameters are invalid.</li>
343 <li>401 : authority information lacks or is invalid.</li>
344 <li>403 : the account has not the permission.</li>
345 <li>404 : the node does not exist.</li>
346 <li>500 : some errors of due to the server occurred.</li>
347 </ul>
348
349 <p>The result of operation of search or retrieve is sent as message body of response. As the format of the data is plain text whose encoding is UTF-8, it can be structured with tabs and line feeds.</p>
350
351 <h3>Operation of Node Master</h3>
352
353 <p>To operate the node master, connect to the path "/master" of the server. For example, if the host name is "skyhigh.estraier.go.jp" and the port number is 8888, connect to "http://skyhigh.estraier.go.jp:8888/master". Only super users are granted to operate the node master. There are some sub commands for operations of the node master. The name of a sub command is specified by the parameter "action". Other parameters vary according to each sub command.</p>
354
355 <dl>
356 <dt><kbd>/master?action=shutdown</kbd></dt>
357 <dd>Shutdown the node master.</dd>
358 <dd>No parameter is used.</dd>
359 <dd>On success, the status code 202 is returned.</dd>
360 </dl>
361
362 <dl>
363 <dt><kbd>/master?action=userlist</kbd></dt>
364 <dd>Get the list of user accounts.</dd>
365 <dd>No parameter is used.</dd>
366 <dd>On success, the status code 200 is returned. The entity body of response expresses the list of user accounts whose format is TSV. Each line is information of each user. There is fields of the user name, the encrypted password, the flags, the full name, and the miscellaneous information.</dd>
367 </dl>
368
369 <dl>
370 <dt><kbd>/master?action=useradd&amp;name=<var>str</var>&amp;passwd=<var>str</var>&amp;flags=<var>str</var>&amp;fname=<var>str</var>&amp;misc=<var>str</var></kbd></dt>
371 <dd>Add a user account.</dd>
372 <dd><var>name</var> specifies the name of a new user. It is essential. Only alphanumeric characters are in the name. If the specified name overlaps the name of an existing user, it is treated as an error.</dd>
373 <dd><var>passwd</var> specifies the password. It is essantial.</dd>
374 <dd><var>flags</var> specifies the flags. It is optional.</dd>
375 <dd><var>fname</var> specifies the full name. It is optional.</dd>
376 <dd><var>misc</var> specifies the miscellaneous information. It is optional.</dd>
377 <dd>On success, the status code 200 is returned.</dd>
378 <dd>Because the password is sent, POST method should be used.</dd>
379 </dl>
380
381 <dl>
382 <dt><kbd>/master?action=userdel&amp;name=<var>str</var></kbd></dt>
383 <dd>Delete a user account.</dd>
384 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
385 <dd>On success, the status code 200 is returned.</dd>
386 </dl>
387
388 <dl>
389 <dt><kbd>/master?action=nodelist</kbd></dt>
390 <dd>Get the list of node servers.</dd>
391 <dd>No parameter is used.</dd>
392 <dd>On success, the status code 200 is returned. The entity body of response expresses the list of node servers whose format is TSV. Each line is information of each node. There is fields of the node name, the label, the number of documents, the number of unique words, and the size.</dd>
393 </dl>
394
395 <dl>
396 <dt><kbd>/master?action=nodeadd&amp;name=<var>str</var>&amp;label=<var>str</var></kbd></dt>
397 <dd>Add a node server.</dd>
398 <dd><var>name</var> specifies the name of a new node. It is essential. Only alphanumeric characters are in the name. If the specified name overlaps the name of an existing node, it is treated as an error.</dd>
399 <dd><var>label</var> specifies the label. It is optional. If it is omitted, the label is to be the same as the name.</dd>
400 <dd>On success, the status code 200 is returned.</dd>
401 </dl>
402
403 <dl>
404 <dt><kbd>/master?action=nodedel&amp;name=<var>str</var></kbd></dt>
405 <dd>Delete a node server.</dd>
406 <dd><var>name</var> specifies the name of a node. It is essential.</dd>
407 <dd>On success, the status code 200 is returned.</dd>
408 </dl>
409
410 <h3>Operation of Node Server</h3>
411
412 <p>To operate a node server, connect to a path which begins "/node/" and is followed by the name of the node. For example, if the host name is "skyhigh.estraier.go.jp" and the port number is 8888 and the name of the node is "foo", connect to "http://skyhigh.estraier.go.jp:8888/node/foo". There are some sub commands for operations of node servers. The name of a sub command is specified after the node name. Parameters vary according to each sub command.</p>
413
414 <dl>
415 <dt><kbd>/node/<var>name</var>/inform</kbd></dt>
416 <dd>Get information of a node.</dd>
417 <dd>No parameter is used.</dd>
418 <dd>On success, the status code 200 is returned. The entity body of response expresses node information whose format is TSV. The first line includes fields of the node name, the label, the number of documents, the number of unique words, and the size. The next line is empty. The succeeding lines to the next empty line are names of administrators. And, the succeeding lines to the next empty line are names of normal users. And, the succeeding lines to the end are link information. There are fields of the URL, the label, and the credit.</dd>
419 </dl>
420
421 <dl>
422 <dt><kbd>/node/<var>name</var>/search?phrase=<var>str</var>&amp;attr=<var>str</var>&amp;order=<var>str</var>&amp;max=<var>num</var>&amp;options=<var>num</var>&amp;depth=<var>num</var></kbd></dt>
423 <dd>Search for documents.</dd>
424 <dd><var>phrase</var> specifies the search phrase. It is optional. The format is as with the one of the core API.</dd>
425 <dd><var>attr</var> specifies an attribute search condition. It is optional. From <var>attr1</var> to <var>attr9</var> works as with it. The format is as with the one of the core API.</dd>
426 <dd><var>order</var> specifies the order expression. It is optional. The format is as with the one of the core API.</dd>
427 <dd><var>max</var> specifies the maximum number of shown documents. It is optional. By default, it is 10.</dd>
428 <dd><var>options</var> specifies options. It is optional. The value is as with the one of the core API.</dd>
429 <dd><var>depth</var> specifies depth of meta search. It is optional. By default, it is 0.</dd>
430 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is explained later.</dd>
431 </dl>
432
433 <dl>
434 <dt><kbd>/node/<var>name</var>/get_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
435 <dd>Get information of a document.</dd>
436 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
437 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
438 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is document draft.</dd>
439 </dl>
440
441 <dl>
442 <dt><kbd>/node/<var>name</var>/get_doc_attr?id=<var>num</var>&amp;uri=<var>str</var>&amp;attr=<var>str</var></kbd></dt>
443 <dd>Get the value of an attribute of a document.</dd>
444 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
445 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
446 <dd><var>attr</var> specifies the name of an attribute. It is essential.</dd>
447 <dd>On success, the status code 200 is returned. The entity body of response expresses the value of the attribute.</dd>
448 </dl>
449
450 <dl>
451 <dt><kbd>/node/<var>name</var>/uri_to_id?uri=<var>str</var></kbd></dt>
452 <dd>Get the ID number of a document specified by URI.</dd>
453 <dd><var>uri</var> specifies the URI of a document. It is essential.</dd>
454 <dd>On success, the status code 200 is returned. The entity body of response expresses the ID number of the document.</dd>
455 </dl>
456
457 <dl>
458 <dt><kbd>/node/<var>name</var>/put_doc?draft=<var>str</var></kbd></dt>
459 <dd>Register a docuemnt. It is available by administrators only.</dd>
460 <dd><var>draft</var> specifies content of a document in document draft format. It is essential.</dd>
461 <dd>On success, the status code 200 is returned.</dd>
462 </dl>
463
464 <dl>
465 <dt><kbd>/node/<var>name</var>/out_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
466 <dd>Remove a document. It is available by administrators only.</dd>
467 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
468 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
469 <dd>On success, the status code 200 is returned.</dd>
470 </dl>
471
472 <dl>
473 <dt><kbd>/node/<var>name</var>/_set_user?name=<var>str</var>&amp;mode=<var>num</var></kbd></dt>
474 <dd>Set permission of a user. It is available by administrators only.</dd>
475 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
476 <dd><var>mode</var> specifies operation mode. It is essential. 1 means to set the user as an administrator, 2 means to set the user as a normal user, and 0 means to revoke the user account.</dd>
477 <dd>On success, the status code 200 is returned.</dd>
478 </dl>
479
480 <dl>
481 <dt><kbd>/node/<var>name</var>/_set_link?url=<var>str</var>&amp;label=<var>str</var>&amp;credit=<var>num</var></kbd></dt>
482 <dd>Set a link to another node. It is available by administrators only.</dd>
483 <dd><var>url</var> specifies the URL of a destination node. It is essential. If the specified URL overlaps the URL of an existing link, the label and the credit is overwritten.</dd>
484 <dd><var>label</var> specifies the label of the link. It is essential.</dd>
485 <dd><var>credit</var> specifies the credit of the link. It is optional. If it is omitted, the link is removed.</dd>
486 <dd>On success, the status code 200 is returned.</dd>
487 </dl>
488
489 <p>Note that while super users has permission to administrate all nodes, an administrator of a node may not be a super user. Moreover, setting of normal users of each node have meaning only when the authorization mode is 3 (all).</p>
490
491 <h3>Format of Search Result</h3>
492
493 <p>The format of the entitiy body of result of search command is alike to multipart of MIME. The following is an example.</p>
494
495 <pre>--------[2387AD2E34554FFF]--------
496 VERSION 0.9
497 NODE http://localhost:1978/node/sample1
498 HIT 2
499 HINT#1 give 2
500 DOCNUM 2
501 WORDNUM 31
502 TIME 0.001
503 LINK#0 http://localhost:1978/node/sample1 Sample1 10000 2 31 2731304 2
504 LINK#1 http://localhost:1978/node/sample2 Sample2 4000 3 125 8524522 1
505 VIEW SNIPPET
506
507 --------[2387AD2E34554FFF]--------
508 #nodelabel=Sample Node One
509 #nodeurl=http://localhost:1978/node/sample1
510 @id=1
511 @uri=http://localhost/foo.html
512
513 You may my glories and my state dispose, But not my griefs; still am I king of those. (
514 Give give
515 it u
516
517 p, Yo!
518 Give give
519 it up, Yo!)
520
521 --------[2387AD2E34554FFF]--------
522 #nodelabel=Sample Node One
523 #nodeurl=http://localhost:1978/node/sample1
524 @id=2
525 @uri=http://localhost/bar.html
526
527 The faster I go, the behinder I get. (
528 Give give
529 it up, Yo!
530 Give give
531 it up, Yo!)
532
533 --------[2387AD2E34554FFF]--------:END
534 </pre>
535
536 <p>Each line feed is a single LF. The first line is definition of the border string. Each parts are delimited by the border string. The last border string is followed by ":END". The first part is the meta section. The other parts are document sections.</p>
537
538 <p>The format of the meta section is TSV. Meaning of each string is picked out by the first field. There are the following kinds.</p>
539
540 <ul>
541 <li><kbd>VERSION</kbd> : specifies the version of the protocol.</li>
542 <li><kbd>NODE</kbd> : specifies the URL of the node.</li>
543 <li><kbd>HIT</kbd> : specifies the total number of the corresponding documents.</li>
544 <li><kbd>HINT#<var>n</var></kbd> : specifies the number of documents correspondign each word. The second field specifies the word. The third field specifies the number.</li>
545 <li><kbd>DOCNUM</kbd> : specifies the total number of documents in target nodes.</li>
546 <li><kbd>WORDNUM</kbd> : specifies the total number of words in target nodes.</li>
547 <li><kbd>TIME</kbd> : specifies elapsed time in milliseconds.</li>
548 <li><kbd>LINK#<var>n</var></kbd> : specifies information of each linked node. Fields express the URL, the label, the credit, the number of documents, the number of unique words, the size of the database, and the number of corresponding documents. LINK#0 means the node it self.</li>
549 <li><kbd>VIEW</kbd> : specifies the format of document parts. As for now, it is constantly "SNIPPET".</li>
550 </ul>
551
552 <p>Each document part expresses attributes and a snippet of a document. Top lines to the first empty line expresses attributes. Their format is as with the one of document draft. The format of the snippet is TSV. There are tab separated values. Each line is a string to be shown. Though most lines have only one field, some lines have two fields. If the second field exists, the first field is to be shown with highlighted, and the second field means its normalized form.</p>
553
554 <p>The following pseudo-attributes are added to each result documents of the search command or the get_doc command includes.</p>
555
556 <ul>
557 <li><kbd>#nodeurl</kbd> : specifies the URL of the node into which the document was registered.</li>
558 <li><kbd>#nodelabel</kbd> : specifies the label of the node into which the document was registered.</li>
559 </ul>
560
561 <h3>Special Format for Document Registration</h3>
562
563 <p>Because URL encoding is not efficient as for large data sent for the put_doc command, the raw mode is supported. If the value of "Content-Type" is "text/x-estraier-draft", the entity body is treated as a document draft itself. The following is an example.</p>
564
565 <pre>POST /node/foo/put_doc HTTP/1.0
566 Content-Type: text/x-estraier-draft
567 Content-Length: 138
568
569 @uri=http://gogo.estraier.go.jp/sample.html
570 @title=Twinkle Twinkle Little Star
571
572 Twinkle, twinkle, little star,
573 How I wonder what you are.
574 </pre>
575
576 <hr />
577
578 <h2 id="nodeapi">Node API</h2>
579
580 <p>As it is a bother to implement HTTP, the node API is useful. This section describes how to use the node API.</p>
581
582 <h3>Introduction</h3>
583
584 <p>Using the node API, you can implement clients communicating node severs without considering such low level processing as TCP/IP and HTTP. Though the node API has overhead comparing to the core API, it is important to be able to execute at remote host and to perform parallel processing without discrimination of readers and writers.</p>
585
586 <p>In each source of applications of the node API, include `estraier.h', `estnode.h', `cabin.h', and `stdlib.h'.</p>
587
588 <pre>#include &lt;estraier.h&gt;
589 #include &lt;estnode.h&gt;
590 #include &lt;cabin.h&gt;
591 #include &lt;stdlib.h&gt;
592 </pre>
593
594 <p>To build an application, perform the following command. It is same as with the core API.</p>
595
596 <pre>gcc `estconfig --cflags` -o foobar foobar.c `estconfig --ldflags` `estconfig --libs`
597 </pre>
598
599 <p>Because the node API uses features of the core API also, if you have never read <a href="pguide-en.html">the programming guide</a>, please read it beforehand.</p>
600
601 <h3>API for Initializing</h3>
602
603 <p>For preparation to use the node API, initialize the network environment at the beginning of a program. Moreover, the environment should be freed at the end of the program.</p>
604
605 <p>The function `est_init_net_env' is used in order to initialize the networking environment.</p>
606
607 <dl>
608 <dt><kbd>int est_init_net_env(void);</kbd></dt>
609 <dd>The return value is true if success, else it is false.</dd>
610 </dl>
611
612 <p>The function `est_free_net_env' is used in order to free the networking environment.</p>
613
614 <dl>
615 <dt><kbd>void est_free_net_env(void);</kbd></dt>
616 <dd>There is no parameter and no return value.</dd>
617 </dl>
618
619 <h3>API for Nodes</h3>
620
621 <p>The type of the structure `ESTNODE' is for abstraction of connection to a node. A node has its own URL. No entitiy of `ESTNODE' is accessed directly, but it is accessed by the pointer. The term of "node connection object" means the pointer and its referent. A node connection object is created by the function `est_node_new' and destroyed by `est_node_delete'. Every created node connection object should be destroyed.</p>
622
623 <p>The following is a typical use case of node connection object.</p>
624
625 <pre>ESTNODE *node;
626
627 /* create a node connection object */
628 node = est_node_new("http://estraier.gov:1978/node/foo");
629
630 /* set the proxy, the timeout, and the autority */
631 est_node_set_proxy(node, "proxy.qdbm.go.jp", 8080);
632 est_node_set_timeout(node, 5);
633 est_node_set_auth(node, "mikio", "oikim");
634
635 /* register documents or search for documents here */
636
637 /* destroy the object */
638 est_node_delete(node);
639 </pre>
640
641 <p>The function `est_node_new' is used in order to create a node connection object.</p>
642
643 <dl>
644 <dt><kbd>ESTNODE *est_node_new(const char *<var>url</var>);</kbd></dt>
645 <dd>`url' specifies the URL of a node. The return value is a node connection object.</dd>
646 </dl>
647
648 <p>The function `est_node_delete' is used in order to destroy a node connection object.</p>
649
650 <dl>
651 <dt><kbd>void est_node_delete(ESTNODE *<var>node</var>);</kbd></dt>
652 <dd>`node' specifies a node connection object.</dd>
653 </dl>
654
655 <p>The function `est_node_status' is used in order to get the status code of the last request of a node.</p>
656
657 <dl>
658 <dt><kbd>int est_node_status(ESTNODE *<var>node</var>);</kbd></dt>
659 <dd>`node' specifies a node connection object. The return value is the status code of the last request of the node. -1 means failure of connection.</dd>
660 </dl>
661
662 <p>The function `est_node_set_proxy' is used in order to set the proxy information of a node connection object.</p>
663
664 <dl>
665 <dt><kbd>void est_node_set_proxy(ESTNODE *<var>node</var>, const char *<var>host</var>, int <var>port</var>);</kbd></dt>
666 <dd>`node' specifies a node connection object. `host' specifies the host name of a proxy server. `port' specifies the port number of the proxy server.</dd>
667 </dl>
668
669 <p>The function `est_node_set_timeout' is used in order to set timeout of a connection.</p>
670
671 <dl>
672 <dt><kbd>void est_node_set_timeout(ESTNODE *<var>node</var>, int <var>sec</var>);</kbd></dt>
673 <dd>`node' specifies a node connection object. `sec' specifies timeout of the connection in seconds.</dd>
674 </dl>
675
676 <p>The function `est_node_set_auth' is used in order to set the authoririty information of a node connection object.</p>
677
678 <dl>
679 <dt><kbd>void est_node_set_auth(ESTNODE *<var>node</var>, const char *<var>name</var>, const char *<var>passwd</var>);</kbd></dt>
680 <dd>`node' specifies a node connection object. `name' specifies the name of an authority. `passwd' specifies the password of the authority.</dd>
681 </dl>
682
683 <p>The function `est_node_put_doc' is used in order to add a document to a node.</p>
684
685 <dl>
686 <dt><kbd>int est_node_put_doc(ESTNODE *<var>node</var>, ESTDOC *<var>doc</var>);</kbd></dt>
687 <dd>`node' specifies a node connection object. `doc' specifies a document object. The document object should have the URI attribute. The return value is true if success, else it is false. If the URI attribute is same with an existing document in the node, the existing one is deleted.</dd>
688 </dl>
689
690 <p>The function `est_node_out_doc' is used in order to remove a document from a node.</p>
691
692 <dl>
693 <dt><kbd>int est_node_out_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
694 <dd>`node' specifies a node connection object. `id' specifies the ID number of a registered document. The return value is true if success, else it is false.</dd>
695 </dl>
696
697 <p>The function `est_node_out_doc_by_uri' is used in order to remove a document specified by URI from a node.</p>
698
699 <dl>
700 <dt><kbd>int est_node_out_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
701 <dd>`node' specifies a node connection object. `uri' specifies the URI of a registered document. The return value is true if success, else it is false.</dd>
702 </dl>
703
704 <p>The function `est_node_get_doc' is used in order to retrieve a document in a node.</p>
705
706 <dl>
707 <dt><kbd>ESTDOC *est_node_get_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
708 <dd>`node' specifies a node connection object. `id' specifies the ID number of a registered document. The return value is a document object. It should be deleted with `est_doc_delete' if it is no longer in use. On error, `NULL' is returned.</dd>
709 </dl>
710
711 <p>The function `est_node_get_doc_by_uri' is used in order to retrieve a document specified by URI in a node.</p>
712
713 <dl>
714 <dt><kbd>ESTDOC *est_node_get_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
715 <dd>`node' specifies a node connection object. `uri' specifies the URI of a registered document. The return value is a document object. It should be deleted with `est_doc_delete' if it is no longer in use. On error, `NULL' is returned.</dd>
716 </dl>
717
718 <p>The function `est_node_get_doc_attr' is used in order to retrieve the value of an attribute of a document in a node.</p>
719
720 <dl>
721 <dt><kbd>char *est_node_get_doc_attr(ESTNODE *<var>node</var>, int <var>id</var>, const char *<var>name</var>);</kbd></dt>
722 <dd>`node' specifies a node connection object. `id' specifies the ID number of a registered document. `name' specifies the name of an attribute. The return value is the value of the attribute or `NULL' if it does not exist. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.</dd>
723 </dl>
724
725 <p>The function `est_node_get_doc_attr_by_uri' is used in order to retrieve the value of an attribute of a document specified by URI in a node.</p>
726
727 <dl>
728 <dt><kbd>char *est_node_get_doc_attr_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>, const char *<var>name</var>);</kbd></dt>
729 <dd>`node' specifies a node connection object. `uri' specifies the URI of a registered document. `name' specifies the name of an attribute. The return value is the value of the attribute or `NULL' if it does not exist. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.</dd>
730 </dl>
731
732 <p>The function `est_node_uri_to_id' is used in order to get the ID of a document spacified by URI.</p>
733
734 <dl>
735 <dt><kbd>int est_node_uri_to_id(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
736 <dd>`node' specifies a node connection object. `uri' specifies the URI of a registered document. The return value is the ID of the document. On error, -1 is returned.</dd>
737 </dl>
738
739 <p>The function `est_node_name' is used in order to get the name of a node.</p>
740
741 <dl>
742 <dt><kbd>const char *est_node_name(ESTNODE *<var>node</var>);</kbd></dt>
743 <dd>`node' specifies a node connection object. The return value is the name of the node. On error, `NULL' is returned. The life duration of the returned string is synchronous with the one of the node object.</dd>
744 </dl>
745
746 <p>The function `est_node_label' is used in order to get the label of a node.</p>
747
748 <dl>
749 <dt><kbd>const char *est_node_label(ESTNODE *<var>node</var>);</kbd></dt>
750 <dd>`node' specifies a node connection object. The return value is the label of the node. On error, `NULL' is returned. The life duration of the returned string is synchronous with the one of the node object.</dd>
751 </dl>
752
753 <p>The function `est_node_doc_num' is used in order to get the number of documents in a node.</p>
754
755 <dl>
756 <dt><kbd>int est_node_doc_num(ESTNODE *<var>node</var>);</kbd></dt>
757 <dd>`node' specifies a node connection object. The return value is the number of documents in the node. On error, -1 is returned.</dd>
758 </dl>
759
760 <p>The function `est_node_word_num' is used in order to get the number of unique words in a node.</p>
761
762 <dl>
763 <dt><kbd>int est_node_word_num(ESTNODE *<var>node</var>);</kbd></dt>
764 <dd>`node' specifies a node connection object. The return value is the number of unique words in the node. On error, -1 is returned.</dd>
765 </dl>
766
767 <p>The function `est_node_size' is used in order to get the size of the datbase of a node.</p>
768
769 <dl>
770 <dt><kbd>double est_node_size(ESTNODE *<var>node</var>);</kbd></dt>
771 <dd>`node' specifies a node connection object. The return value is the size of the datbase of the node. On error, -1.0 is returned.</dd>
772 </dl>
773
774 <p>The function `est_node_search' is used in order to search documents corresponding a condition for a node.</p>
775
776 <dl>
777 <dt><kbd>ESTNODERES *est_node_search(ESTNODE *<var>node</var>, ESTCOND *<var>cond</var>, int <var>depth</var>);</kbd></dt>
778 <dd>`node' specifies a node connection object. `cond' specifies a condition object. `depth' specifies the depth of meta search. The return value is a node result object. It should be deleted with `est_noderes_delete' if it is no longer in use. On error, `NULL' is returned.</dd>
779 </dl>
780
781 <p>The function `est_node_set_user' is used in order to manage a user account of a node.</p>
782
783 <dl>
784 <dt><kbd>int est_node_set_user(ESTNODE *<var>node</var>, const char *<var>name</var>, int <var>mode</var>);</kbd></dt>
785 <dd>`node' specifies a node connection object. `name' specifies the name of a user. `mode' specifies the operation mode. 0 means to delete the account. 1 means to set the account as an administrator. 2 means to set the account as a normal user. The return value is true if success, else it is false.</dd>
786 </dl>
787
788 <p>The function `est_node_set_link' is used in order to manage a link of a node.</p>
789
790 <dl>
791 <dt><kbd>int est_node_set_link(ESTNODE *<var>node</var>, const char *<var>url</var>, const char *<var>label</var>, int <var>credit</var>);</kbd></dt>
792 <dd>`node' specifies a node connection object. `url' specifies the URL of the target node of a link. `label' specifies the label of the link. `credit' specifies the credit of the link. If it is negative, the link is removed. The return value is true if success, else it is false.</dd>
793 </dl>
794
795 <h3>API for Search Results of Nodes</h3>
796
797 <p>The type of the structure `ESTNODERES' is for abstraction of search result from a node. A result is composed of a list of corresponding documents and information of hints. No entitiy of `ESTNODERES' is accessed directly, but it is accessed by the pointer. The term of "node result object" means the pointer and its referent. A node result object is created by the function `est_node_search' and destroyed by `est_noderes_delete'. Every created node connection object should be destroyed.</p>
798
799 <p>The type of the structure `ESTRESDOC' is for abstraction of a document in search result. A result document is composed of some attributes and a snippet. No entitiy of `ESTRESDOC' is accessed directly, but it is accessed by the pointer. The term of "result document object" means the pointer and its referent. A result document object is gotten by the function `est_noderes_get_doc' but it should not be destroyed because the entity is managed inside the node result object.</p>
800
801 <p>The following is a typical use case of node connection object and result document object.</p>
802
803 <pre>ESTNODERES *nres;
804 CBMAP *hints;
805 ESTRESDOC *rdoc;
806 int i;
807
808 /* create a node result object */
809 nres = est_node_search(node, cond, 1);
810
811 /* get hints */
812 hints = est_noderes_hints(nres);
813
814 /* show the hints here */
815
816 /* scan documents in the result */
817 for(i = 0; i &lt; est_noderes_doc_num(nres); i++){
818
819 /* get a result document object */
820 rdoc = est_noderes_get_doc(nres, i);
821
822 /* show the result document object here */
823
824 }
825
826 /* destroy the node result object */
827 est_noderes_delete(nres);
828 </pre>
829
830 <p>The function `est_noderes_delete' is used in order to delete a node result object.</p>
831
832 <dl>
833 <dt><kbd>void est_noderes_delete(ESTNODERES *<var>nres</var>);</kbd></dt>
834 <dd>`nres' specifies a node result object.</dd>
835 </dl>
836
837 <p>The function `est_noderes_hints' is used in order to get a map object for hints of a node result object.</p>
838
839 <dl>
840 <dt><kbd>CBMAP *est_noderes_hints(ESTNODERES *<var>nres</var>);</kbd></dt>
841 <dd>`nres' specifies a node result object. The return value is a map object for hints. Keys of the map are "VERSION", "NODE", "HIT", "HINT#n", "DOCNUM", "WORDNUM", "TIME", "LINK#n", and "VIEW". The life duration of the returned object is synchronous with the one of the node result object.</dd>
842 </dl>
843
844 <p>The function `est_noderes_doc_num' is used in order to get the number of documents in a node result object.</p>
845
846 <dl>
847 <dt><kbd>int est_noderes_doc_num(ESTNODERES *<var>nres</var>);</kbd></dt>
848 <dd>`nres' specifies a node result object. The return value is the number of documents in a node result object.</dd>
849 </dl>
850
851 <p>The function `est_noderes_get_doc' is used in order to refer a result document object in a node result object.</p>
852
853 <dl>
854 <dt><kbd>ESTRESDOC *est_noderes_get_doc(ESTNODERES *<var>nres</var>, int <var>index</var>);</kbd></dt>
855 <dd>`nres' specifies a node result object. `index' specifies the index of a document. The return value is a result document object or `NULL' if `index' is equal to or more than the number of documents. The life duration of the returned object is synchronous with the one of the node result object.</dd>
856 </dl>
857
858 <p>The function `est_resdoc_uri' is used in order to get the URI of a result document object.</p>
859
860 <dl>
861 <dt><kbd>const char *est_resdoc_uri(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
862 <dd>`rdoc' specifies a result document object. The return value is the URI of the result document object. The life duration of the returned string is synchronous with the one of the result document object.</dd>
863 </dl>
864
865 <p>The function `est_resdoc_attr_names' is used in order to get a list of attribute names of a result document object.</p>
866
867 <dl>
868 <dt><kbd>CBLIST *est_resdoc_attr_names(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
869 <dd>`rdoc' specifies a result document object. The return value is a new list object of attribute names of the result document object. Because the object of the return value is opened with the function `cblistopen', it should be closed with the function `cblistclose' if it is no longer in use.</dd>
870 </dl>
871
872 <p>The function `est_resdoc_attr' is used in order to get the value of an attribute of a result document object.</p>
873
874 <dl>
875 <dt><kbd>const char *est_resdoc_attr(ESTRESDOC *<var>rdoc</var>, const char *<var>name</var>);</kbd></dt>
876 <dd>`rdoc' specifies a result document object. `name' specifies the name of an attribute. The return value is the value of the attribute or `NULL' if it does not exist. The life duration of the returned string is synchronous with the one of the result document object.</dd>
877 </dl>
878
879 <p>The function `est_resdoc_snippet' is used in order to get the snippet of a result document object.</p>
880
881 <dl>
882 <dt><kbd>const char *est_resdoc_snippet(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
883 <dd>`rdoc' specifies a result document object. The return value is the snippet of the result document object. There are tab separated values. Each line is a string to be shown. Though most lines have only one field, some lines have two fields. If the second field exists, the first field is to be shown with highlighted, and the second field means its normalized form. The life duration of the returned string is synchronous with the one of the result document object.</dd>
884 </dl>
885
886 <h3>Paralleling</h3>
887
888 <p>Each of node connection objects, node result objects, and result document objects can not be shared by threads. If you use multi threads, make eath thread have its own objects. If the precondition is kept, functions of the node API can be treated as thread-safe functions.</p>
889
890 <hr />
891
892 <h2 id="estcall">Command of a Client</h2>
893
894 <p>`estcall' is provided as a client command to manage the node server. This section describes how to use estcall.</p>
895
896 <h3>Synopsis and Description</h3>
897
898 <p>estcall is an aggregation of sub commands. The name of a sub command is specified by the first argument. Other arguments are parsed according to each sub command. The argument <var>nurl</var> specifies the URL of a node. The option -proxy specifies the host name and the port number of a proxy server. The option -tout specifies timeout in seconds. The option -auth specifies the user name and the password of authority information.</p>
899
900 <dl>
901 <dt><kbd>estcall put [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> [<var>file</var>]</kbd></dt>
902 <dd>Register a document of document draft to a node.</dd>
903 <dd><var>file</var> specifies a target file. If it is omitted, the standard input is read.</dd>
904 </dl>
905
906 <dl>
907 <dt><kbd>estcall out [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> <var>expr</var></kbd></dt>
908 <dd>Remove information of a document from a node.</dd>
909 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
910 </dl>
911
912 <dl>
913 <dt><kbd>estcall get [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> <var>expr</var> [<var>attr</var>]</kbd></dt>
914 <dd>Output document draft of a document in a node.</dd>
915 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
916 <dd>If <var>attr</var> is specified, only the value of the attribute is output.</dd>
917 </dl>
918
919 <dl>
920 <dt><kbd>estcall uriid [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> <var>uri</var></kbd></dt>
921 <dd>Output the ID number of a document specified by URI.</dd>
922 <dd><var>uri</var> specifies the URI of a document.</dd>
923 </dl>
924
925 <dl>
926 <dt><kbd>estcall inform [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var></kbd></dt>
927 <dd>Outout the name, the label, the number of documents, and the number of unique words of a node.</dd>
928 </dl>
929
930 <dl>
931 <dt><kbd>estcall search [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] [-vx] [-attr <var>expr</var>] [-ord <var>expr</var>] [-max <var>num</var>] [-dpt <var>num</var>] <var>nurl</var> [<var>phrase</var>]</kbd></dt>
932 <dd>Search a node for documents.</dd>
933 <dd><var>phrase</var> specifies the search phrase.</dd>
934 <dd>If -vx is specified, XML including including attributes and snippets is output.</dd>
935 <dd>-attr specifies an attribute search condition. This option can be specified multiple times.</dd>
936 <dd>-ord specifies the order expression. By default, it is descending by score.</dd>
937 <dd>-max specifies the maximum number of show documents. Negative means unlimited. By default, it is 10.</dd>
938 <dd>-dpt specifies depth of meta search. by default it is 0.</dd>
939 </dl>
940
941 <dl>
942 <dt><kbd>estcall setuser [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> <var>name</var> <var>mode</var></kbd></dt>
943 <dd>Set permission of a user.</dd>
944 <dd><var>name</var> specifies the name of a user.</dd>
945 <dd><var>mode</var> specifies operation mode. 1 means to set the user as an administrator, 2 means to set the user as a normal user, and 0 means to revoke the user account.</dd>
946 </dl>
947
948 <dl>
949 <dt><kbd>estcall setlink [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] <var>nurl</var> <var>url</var> <var>label</var> <var>credit</var></kbd></dt>
950 <dd>Set a link to another node.</dd>
951 <dd><var>url</var> specifies the URL of a destination node.</dd>
952 <dd><var>label</var> specifies the label of the link.</dd>
953 <dd><var>credit</var> specifies the credit of the link. If the value is negative, the link is removed.</dd>
954 </dl>
955
956 <dl>
957 <dt><kbd>estcall raw [-proxy <var>host</var>:<var>port</var>] [-tout <var>num</var>] [-auth <var>user</var> <var>pass</var>] [-np] [-eh <var>expr</var>] <var>url</var> [<var>file</var>]</kbd></dt>
958 <dd>Outout response of an HTTP request.</dd>
959 <dd><var>url</var> specifies the URL of a target.</dd>
960 <dd>If <var>file</var> is specified, the content is sent by POST method. If not, GET method is used. If "-" is specified, the standart input is read.</dd>
961 <dd>If -np is specified, output response headers also.</dd>
962 <dd>-eh specifies an additional HTTP header. By default, "Host", "Connection", "User-Agent", and "Content-Length" is added.</dd>
963 </dl>
964
965 <p>All sub commands return 0 if the operation is success, else return 1.</p>
966
967 <h3>Examples</h3>
968
969 <p>Operations for the node maser itself is not provided as APIs, use the raw sub command for that purpose. For example, the following command is used in order to shutdown the node master.</p>
970
971 <pre>estcall raw -auth admin admin \
972 'http://localhost:1978/master?action=shutdown'
973 </pre>
974
975 <p>In order to add a user, perform the following command.</p>
976
977 <pre>estcall raw -auth admin admin \
978 'http://localhost:1978/master?action=useradd&amp;name=mikio&amp;passwd=iloveyou'
979 </pre>
980
981 <p>In order to use POST method, perform the following command.</p>
982
983 <pre>echo -n 'action=useradd&amp;name=mikio&amp;passwd=iloveyou' |
984 estcall raw -auth admin admin \
985 -eh 'Content-Type: application/x-www-form-urlencoded' \
986 'http://localhost:1978/master' -
987 </pre>
988
989 <hr />
990
991 </body>
992
993 </html>
994
995 <!-- END OF FILE -->

  ViewVC Help
Powered by ViewVC 1.1.26