/[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 4 - (show annotations)
Sat Jul 30 10:45:45 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/html
File size: 55630 byte(s)
first cut at P2P document

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 2</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 Hyper Estraier's client/server (C/S) and peer to peer (P2P) architecture. If you haven't read <a href="uguide-en.html">user's guide</a> yet, now is a good moment to do so.
49 o
50 <p>There was several problems which where motivation for C/S architecture. estseek.cgi is inefficient because it has to reconnect to database for each search query. Database updates using estcmd prevented searches on same database because estcmd uses locks when doing update. To solve those problems, estmaster server process is implemented. This process is resident in memory, has control over databaseses and provides services via network. This approach also has following advantages:
51 </p>
52
53 <ul>
54 <li>server and clients can be distributed across different machines</li>
55 <li>multiple clients and servers can work in parallel</li>
56 <li>client crash doesn't leave database in inconsistent state</li>
57 <li>clients implementation isn't specific to any programming language</li>
58 </ul>
59
60 <p>Protocol between clients and servers is based on HTTP, so normal web browsers can be used as simple clients. Clients can be implemented using any languages which supports HTTP protocol like JavaScript or Flash.
61 </p>
62
63 <p>Distributed processing is based on peer to peer (P2P) architecture. For example, if you use 10 servers, each with million documents, you can search 10 million documents without much additional effort. Since all servers are equal, search service is provided even if some of servers are unavailable. There is notion of relevance of each server which can improve search results (if some parts of index is more important that others).
64 </p>
65
66 <p class="note">
67 Relevance was called reliability in previous version of this document.
68 </p>
69
70 <p>This document describes node API which can be used by client applications to implement search capabilities without using network protocol between client and server.
71
72 <hr />
73
74 <h2 id="architecture">Architecture</h2>
75
76 <p>This section describes the P2P architecture of Hyper Estraier.</p>
77
78 <h3>Node Master and Node Server</h3>
79
80 <p>When using multiple indexes it is inefficient to run one server for each index. estmaster is server process which is implemented as single process which use network port and can provide search services for multiple indexes. Since each index can be searched individually, we can think of "node master" as collection of indexes which are served by single estmaster process. Each index is called "node server" (you can think of it as virtual server) and each has unique URL. Client application knows URL of node server but doesn't need to know to which node master particular index corresponds.</p>
81
82 <div class="illust"><img src="nodeframe.png" width="720" height="350" alt="[framework]" /></div>
83
84 <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>
85
86 <h3>Meta Search and Credit</h3>
87
88 <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>
89
90 <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>
91
92 <div class="illust"><img src="metatree.png" width="720" height="400" alt="[tree of meta search]" /></div>
93
94 <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>
95
96 <h3>Authentication</h3>
97
98 <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>
99
100 <hr />
101
102 <h2 id="tutorial">Tutorial</h2>
103
104 <p>As the concept of P2P seems difficult, let's try to use some commands and learn it by degrees.</p>
105
106 <h3>Start and Stop</h3>
107
108 <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>
109
110 <pre>estmaster init casket
111 </pre>
112
113 <p>Next, start the node master. Perform the following command.</p>
114
115 <pre>estmaster start casket
116 </pre>
117
118 <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>
119
120 <pre>estmaster stop casket
121 </pre>
122
123 <h3>Administration Interface</h3>
124
125 <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>
126
127 <p>If you step into "Manage Master" and select "SHUTDOWN", you can stop the node master. But, leave it for now.</p>
128
129 <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>
130
131 <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>
132
133 <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>
134
135 <h3>Register Documents</h3>
136
137 <p>Back to the command line operations. As the terminal of the node master is busy to show log messages, open another terminal.</p>
138
139 <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>
140
141 <pre>@uri=data001
142 @title=Material Girl
143
144 Living in a material world
145 And I am a material girl
146 You know that we are living in a material world
147 And I am a material girl
148 </pre>
149
150 <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>
151
152 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test1 data001.est
153 </pre>
154
155 <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>
156
157 <pre>@uri=data002
158 @title=Liberian Girl
159
160 Liberian girl
161 You came and you changed My world
162 A love so brand new
163 </pre>
164
165 <p>Then, perform the following command.</p>
166
167 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test2 data002.est
168 </pre>
169
170 <p>It is useful to register documents from remote machines, isn't it? As with the above steps, register some other documents.</p>
171
172 <h3>Search for Documents</h3>
173
174 <p>All right, let's search for some registered documents. Perform the following command, and information of the corresponding document is shown.</p>
175
176 <pre>estcall search http://localhost:1978/node/test1 "material world"
177 </pre>
178
179 <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>
180
181 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
182 http://localhost:1978/node/test2 TEST02 8000
183 </pre>
184
185 <p>And, search again. This time, set depth of meta search with the option -dpt.</p>
186
187 <pre>estcall search -dpt 1 http://localhost:1978/node/test1 "girl"
188 </pre>
189
190 <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>
191
192 <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>
193
194 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
195 http://localhost:1978/node/test2 TEST02 12000
196 </pre>
197
198 <p>You can get result as XML data. Perform the following command. See estresult.dtd for detail of the XML format.</p>
199
200 <pre>estcall search -dpt 1 -vx http://localhost:1978/node/test1 "girl"
201 </pre>
202
203 <p>Each node server embeds search interface for web browsers. Access "http://localhost:1978/node/test1/searchui" to use it.</p>
204
205 <hr />
206
207 <h2 id="estmaster">Command of the Node Master</h2>
208
209 <p>`estmaster' is provided as a command to manage the node master. This section describes how to use estmaster.</p>
210
211 <h3>Synopsis and Description</h3>
212
213 <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>
214
215 <dl>
216 <dt><kbd>estmaster init [-ex] <var>rootdir</var></kbd></dt>
217 <dd>Create the server root directory.</dd>
218 <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>
219 </dl>
220
221 <dl>
222 <dt><kbd>estmaster start [-bg] [-st] <var>rootdir</var></kbd></dt>
223 <dd>Start the node master.</dd>
224 <dd>If -bg is specified, the server runs in background as a daemon process.</dd>
225 <dd>If -st is specified, the server runs in single thread mode.</dd>
226 </dl>
227
228 <dl>
229 <dt><kbd>estmaster stop <var>rootdir</var></kbd></dt>
230 <dd>Stop the running node master.</dd>
231 </dl>
232
233 <dl>
234 <dt><kbd>estmaster unittest <var>rootdir</var></kbd></dt>
235 <dd>Perform unit tests.</dd>
236 </dl>
237
238 <dl>
239 <dt><kbd>estmaster crypt <var>key</var> [<var>hash</var>]</kbd></dt>
240 <dd>Output an encrypted string of a string.</dd>
241 <dd><var>key</var> specifies a target string.</dd>
242 <dd>If <var>hash</var> is specified, it checks whether the key and the hash matches.</dd>
243 </dl>
244
245 <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>
246
247 <p>A running node server sould be finished by valid means by command line or via network. Otherwise, the index may be broken.</p>
248
249 <h3>Constitution of the Server Root Directory</h3>
250
251 <p>The server root directory contains the following files and directories.</p>
252
253 <ul>
254 <li><kbd>_conf</kbd> : prime configuration file.</li>
255 <li><kbd>_user</kbd> : user account file.</li>
256 <li><kbd>_log</kbd> : log file.</li>
257 <li><kbd>_meta</kbd> : database file for meta data.</li>
258 <li><kbd>_pid</kbd> : file recording the process ID.</li>
259 <li><kbd>_stop</kbd> : file to stop the node master.</li>
260 <li><kbd>_node/</kbd> : node directory.</li>
261 <li><kbd>_sess/</kbd> : session directory.</li>
262 </ul>
263
264 <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>
265
266 <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>
267
268 <h3>Prime Configuration File</h3>
269
270 <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>
271
272 <pre>hostname: localhost
273 portnum: 1978
274 runmode: 1
275 authmode: 2
276 maxconn: 30
277 sessiontimeout: 600
278 searchtimeout: 8
279 searchdepth: 5
280 proxyhost:
281 proxyport:
282 loglevel: 2
283 docroot:
284 indexfile:
285 trustednodes:
286 denyuntrusted: 0
287 cachesize: 64
288 specialcache:
289 snipwwidth: 480
290 sniphwidth: 96
291 snipawidth: 96
292 </pre>
293
294 <p>Means of each variable is the following.</p>
295
296 <ul>
297 <li><kbd>hostname</kbd> : specifies the host name of the server.</li>
298 <li><kbd>portnum</kbd> : specifies the port number of the server.</li>
299 <li><kbd>runmode</kbd> : specifies running mode (1:normal, 2:readonly).</li>
300 <li><kbd>authmode</kbd> : specifies authorization mode (1:none, 2:admin, 3:all).</li>
301 <li><kbd>maxconn</kbd> : specifies maximum number of connections at the same time.</li>
302 <li><kbd>sessiontimeout</kbd> : specifies timeout of a session (in seconds).</li>
303 <li><kbd>searchtimeout</kbd> : specifies timeout of search (in seconds).</li>
304 <li><kbd>searchdepth</kbd> : specifies maximum depth of meta search.</li>
305 <li><kbd>proxyhost</kbd> : specifies the host name of the proxy server.</li>
306 <li><kbd>proxyport</kbd> : specifies the port number of the proxy server.</li>
307 <li><kbd>loglevel</kbd> : specifies logging level (1:debug, 2:information, 3:warning, 4:error, 5:none).</li>
308 <li><kbd>docroot</kbd> : specifies document root directory (full path of a directory to be public).</li>
309 <li><kbd>indexfile</kbd> : specifies index file (name of directory index files).</li>
310 <li><kbd>trustednodes</kbd> : specifies decimal IP addresses of trusted nodes (list separated by comma).</li>
311 <li><kbd>denyuntrusted</kbd> : specifies whether to deny all nodes except for trusted nodes (0:no, 1:yes).</li>
312 <li><kbd>cachesize</kbd> : specifies maximum size of the index cache (in mega bytes).</li>
313 <li><kbd>specialcache</kbd> : specifies name of the attribute of the special cache.</li>
314 <li><kbd>snipwwidth</kbd> : specifies whole width of the snippet of each shown document.</li>
315 <li><kbd>sniphwidth</kbd> : specifies width of strings picked up from the beginning of the text.</li>
316 <li><kbd>snipawidth</kbd> : specifies width of strings picked up around each highlighted word.</li>
317 </ul>
318
319 <h3>User Account File</h3>
320
321 <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>
322
323 <pre>admin 21232f297a57a5a743894a0e4a801fc3 s Carolus Magnus Administrator
324 </pre>
325
326 <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>
327
328 <h3>Embedded User Interfaces</h3>
329
330 <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>
331
332 <p>By accessing the URL which is the URL of a node server followed by "/searchui", you can use the search interface.</p>
333
334 <hr />
335
336 <h2 id="protocol">Protocol</h2>
337
338 <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>
339
340 <h3>Introduction</h3>
341
342 <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>
343
344 <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>
345
346 <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>
347
348 <ul>
349 <li>400 : parameters are invalid.</li>
350 <li>401 : authority information lacks or is invalid.</li>
351 <li>403 : the account has not the permission.</li>
352 <li>404 : the node does not exist.</li>
353 <li>500 : some errors of due to the server occurred.</li>
354 </ul>
355
356 <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>
357
358 <h3>Operation of Node Master</h3>
359
360 <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>
361
362 <dl>
363 <dt><kbd>/master?action=shutdown</kbd></dt>
364 <dd>Shutdown the node master.</dd>
365 <dd>No parameter is used.</dd>
366 <dd>On success, the status code 202 is returned.</dd>
367 </dl>
368
369 <dl>
370 <dt><kbd>/master?action=userlist</kbd></dt>
371 <dd>Get the list of user accounts.</dd>
372 <dd>No parameter is used.</dd>
373 <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>
374 </dl>
375
376 <dl>
377 <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>
378 <dd>Add a user account.</dd>
379 <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>
380 <dd><var>passwd</var> specifies the password. It is essantial.</dd>
381 <dd><var>flags</var> specifies the flags. It is optional.</dd>
382 <dd><var>fname</var> specifies the full name. It is optional.</dd>
383 <dd><var>misc</var> specifies the miscellaneous information. It is optional.</dd>
384 <dd>On success, the status code 200 is returned.</dd>
385 <dd>Because the password is sent, POST method should be used.</dd>
386 </dl>
387
388 <dl>
389 <dt><kbd>/master?action=userdel&amp;name=<var>str</var></kbd></dt>
390 <dd>Delete a user account.</dd>
391 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
392 <dd>On success, the status code 200 is returned.</dd>
393 </dl>
394
395 <dl>
396 <dt><kbd>/master?action=nodelist</kbd></dt>
397 <dd>Get the list of node servers.</dd>
398 <dd>No parameter is used.</dd>
399 <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>
400 </dl>
401
402 <dl>
403 <dt><kbd>/master?action=nodeadd&amp;name=<var>str</var>&amp;label=<var>str</var></kbd></dt>
404 <dd>Add a node server.</dd>
405 <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>
406 <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>
407 <dd>On success, the status code 200 is returned.</dd>
408 </dl>
409
410 <dl>
411 <dt><kbd>/master?action=nodedel&amp;name=<var>str</var></kbd></dt>
412 <dd>Delete a node server.</dd>
413 <dd><var>name</var> specifies the name of a node. It is essential.</dd>
414 <dd>On success, the status code 200 is returned.</dd>
415 </dl>
416
417 <h3>Operation of Node Server</h3>
418
419 <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>
420
421 <dl>
422 <dt><kbd>/node/<var>name</var>/inform</kbd></dt>
423 <dd>Get information of a node.</dd>
424 <dd>No parameter is used.</dd>
425 <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>
426 </dl>
427
428 <dl>
429 <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>
430 <dd>Search for documents.</dd>
431 <dd><var>phrase</var> specifies the search phrase. It is optional. The format is as with the one of the core API.</dd>
432 <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>
433 <dd><var>order</var> specifies the order expression. It is optional. The format is as with the one of the core API.</dd>
434 <dd><var>max</var> specifies the maximum number of shown documents. It is optional. By default, it is 10.</dd>
435 <dd><var>options</var> specifies options. It is optional. The value is as with the one of the core API.</dd>
436 <dd><var>depth</var> specifies depth of meta search. It is optional. By default, it is 0.</dd>
437 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is explained later.</dd>
438 </dl>
439
440 <dl>
441 <dt><kbd>/node/<var>name</var>/get_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
442 <dd>Get information of a document.</dd>
443 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
444 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
445 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is document draft.</dd>
446 </dl>
447
448 <dl>
449 <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>
450 <dd>Get the value of an attribute of a document.</dd>
451 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
452 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
453 <dd><var>attr</var> specifies the name of an attribute. It is essential.</dd>
454 <dd>On success, the status code 200 is returned. The entity body of response expresses the value of the attribute.</dd>
455 </dl>
456
457 <dl>
458 <dt><kbd>/node/<var>name</var>/uri_to_id?uri=<var>str</var></kbd></dt>
459 <dd>Get the ID number of a document specified by URI.</dd>
460 <dd><var>uri</var> specifies the URI of a document. It is essential.</dd>
461 <dd>On success, the status code 200 is returned. The entity body of response expresses the ID number of the document.</dd>
462 </dl>
463
464 <dl>
465 <dt><kbd>/node/<var>name</var>/put_doc?draft=<var>str</var></kbd></dt>
466 <dd>Register a docuemnt. It is available by administrators only.</dd>
467 <dd><var>draft</var> specifies content of a document in document draft format. It is essential.</dd>
468 <dd>On success, the status code 200 is returned.</dd>
469 </dl>
470
471 <dl>
472 <dt><kbd>/node/<var>name</var>/out_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
473 <dd>Remove a document. It is available by administrators only.</dd>
474 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
475 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
476 <dd>On success, the status code 200 is returned.</dd>
477 </dl>
478
479 <dl>
480 <dt><kbd>/node/<var>name</var>/_set_user?name=<var>str</var>&amp;mode=<var>num</var></kbd></dt>
481 <dd>Set permission of a user. It is available by administrators only.</dd>
482 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
483 <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>
484 <dd>On success, the status code 200 is returned.</dd>
485 </dl>
486
487 <dl>
488 <dt><kbd>/node/<var>name</var>/_set_link?url=<var>str</var>&amp;label=<var>str</var>&amp;credit=<var>num</var></kbd></dt>
489 <dd>Set a link to another node. It is available by administrators only.</dd>
490 <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>
491 <dd><var>label</var> specifies the label of the link. It is essential.</dd>
492 <dd><var>credit</var> specifies the credit of the link. It is optional. If it is omitted, the link is removed.</dd>
493 <dd>On success, the status code 200 is returned.</dd>
494 </dl>
495
496 <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>
497
498 <h3>Format of Search Result</h3>
499
500 <p>The format of the entitiy body of result of search command is alike to multipart of MIME. The following is an example.</p>
501
502 <pre>--------[2387AD2E34554FFF]--------
503 VERSION 0.9
504 NODE http://localhost:1978/node/sample1
505 HIT 2
506 HINT#1 give 2
507 DOCNUM 2
508 WORDNUM 31
509 TIME 0.001
510 LINK#0 http://localhost:1978/node/sample1 Sample1 10000 2 31 2731304 2
511 LINK#1 http://localhost:1978/node/sample2 Sample2 4000 3 125 8524522 1
512 VIEW SNIPPET
513
514 --------[2387AD2E34554FFF]--------
515 #nodelabel=Sample Node One
516 #nodeurl=http://localhost:1978/node/sample1
517 @id=1
518 @uri=http://localhost/foo.html
519
520 You may my glories and my state dispose, But not my griefs; still am I king of those. (
521 Give give
522 it u
523
524 p, Yo!
525 Give give
526 it up, Yo!)
527
528 --------[2387AD2E34554FFF]--------
529 #nodelabel=Sample Node One
530 #nodeurl=http://localhost:1978/node/sample1
531 @id=2
532 @uri=http://localhost/bar.html
533
534 The faster I go, the behinder I get. (
535 Give give
536 it up, Yo!
537 Give give
538 it up, Yo!)
539
540 --------[2387AD2E34554FFF]--------:END
541 </pre>
542
543 <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>
544
545 <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>
546
547 <ul>
548 <li><kbd>VERSION</kbd> : specifies the version of the protocol.</li>
549 <li><kbd>NODE</kbd> : specifies the URL of the node.</li>
550 <li><kbd>HIT</kbd> : specifies the total number of the corresponding documents.</li>
551 <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>
552 <li><kbd>DOCNUM</kbd> : specifies the total number of documents in target nodes.</li>
553 <li><kbd>WORDNUM</kbd> : specifies the total number of words in target nodes.</li>
554 <li><kbd>TIME</kbd> : specifies elapsed time in milliseconds.</li>
555 <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>
556 <li><kbd>VIEW</kbd> : specifies the format of document parts. As for now, it is constantly "SNIPPET".</li>
557 </ul>
558
559 <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>
560
561 <p>The following pseudo-attributes are added to each result documents of the search command or the get_doc command includes.</p>
562
563 <ul>
564 <li><kbd>#nodeurl</kbd> : specifies the URL of the node into which the document was registered.</li>
565 <li><kbd>#nodelabel</kbd> : specifies the label of the node into which the document was registered.</li>
566 </ul>
567
568 <h3>Special Format for Document Registration</h3>
569
570 <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>
571
572 <pre>POST /node/foo/put_doc HTTP/1.0
573 Content-Type: text/x-estraier-draft
574 Content-Length: 138
575
576 @uri=http://gogo.estraier.go.jp/sample.html
577 @title=Twinkle Twinkle Little Star
578
579 Twinkle, twinkle, little star,
580 How I wonder what you are.
581 </pre>
582
583 <hr />
584
585 <h2 id="nodeapi">Node API</h2>
586
587 <p>As it is a bother to implement HTTP, the node API is useful. This section describes how to use the node API.</p>
588
589 <h3>Introduction</h3>
590
591 <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>
592
593 <p>In each source of applications of the node API, include `estraier.h', `estnode.h', `cabin.h', and `stdlib.h'.</p>
594
595 <pre>#include &lt;estraier.h&gt;
596 #include &lt;estnode.h&gt;
597 #include &lt;cabin.h&gt;
598 #include &lt;stdlib.h&gt;
599 </pre>
600
601 <p>To build an application, perform the following command. It is same as with the core API.</p>
602
603 <pre>gcc `estconfig --cflags` -o foobar foobar.c `estconfig --ldflags` `estconfig --libs`
604 </pre>
605
606 <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>
607
608 <h3>API for Initializing</h3>
609
610 <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>
611
612 <p>The function `est_init_net_env' is used in order to initialize the networking environment.</p>
613
614 <dl>
615 <dt><kbd>int est_init_net_env(void);</kbd></dt>
616 <dd>The return value is true if success, else it is false.</dd>
617 </dl>
618
619 <p>The function `est_free_net_env' is used in order to free the networking environment.</p>
620
621 <dl>
622 <dt><kbd>void est_free_net_env(void);</kbd></dt>
623 <dd>There is no parameter and no return value.</dd>
624 </dl>
625
626 <h3>API for Nodes</h3>
627
628 <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>
629
630 <p>The following is a typical use case of node connection object.</p>
631
632 <pre>ESTNODE *node;
633
634 /* create a node connection object */
635 node = est_node_new("http://estraier.gov:1978/node/foo");
636
637 /* set the proxy, the timeout, and the autority */
638 est_node_set_proxy(node, "proxy.qdbm.go.jp", 8080);
639 est_node_set_timeout(node, 5);
640 est_node_set_auth(node, "mikio", "oikim");
641
642 /* register documents or search for documents here */
643
644 /* destroy the object */
645 est_node_delete(node);
646 </pre>
647
648 <p>The function `est_node_new' is used in order to create a node connection object.</p>
649
650 <dl>
651 <dt><kbd>ESTNODE *est_node_new(const char *<var>url</var>);</kbd></dt>
652 <dd>`url' specifies the URL of a node. The return value is a node connection object.</dd>
653 </dl>
654
655 <p>The function `est_node_delete' is used in order to destroy a node connection object.</p>
656
657 <dl>
658 <dt><kbd>void est_node_delete(ESTNODE *<var>node</var>);</kbd></dt>
659 <dd>`node' specifies a node connection object.</dd>
660 </dl>
661
662 <p>The function `est_node_status' is used in order to get the status code of the last request of a node.</p>
663
664 <dl>
665 <dt><kbd>int est_node_status(ESTNODE *<var>node</var>);</kbd></dt>
666 <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>
667 </dl>
668
669 <p>The function `est_node_set_proxy' is used in order to set the proxy information of a node connection object.</p>
670
671 <dl>
672 <dt><kbd>void est_node_set_proxy(ESTNODE *<var>node</var>, const char *<var>host</var>, int <var>port</var>);</kbd></dt>
673 <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>
674 </dl>
675
676 <p>The function `est_node_set_timeout' is used in order to set timeout of a connection.</p>
677
678 <dl>
679 <dt><kbd>void est_node_set_timeout(ESTNODE *<var>node</var>, int <var>sec</var>);</kbd></dt>
680 <dd>`node' specifies a node connection object. `sec' specifies timeout of the connection in seconds.</dd>
681 </dl>
682
683 <p>The function `est_node_set_auth' is used in order to set the authoririty information of a node connection object.</p>
684
685 <dl>
686 <dt><kbd>void est_node_set_auth(ESTNODE *<var>node</var>, const char *<var>name</var>, const char *<var>passwd</var>);</kbd></dt>
687 <dd>`node' specifies a node connection object. `name' specifies the name of an authority. `passwd' specifies the password of the authority.</dd>
688 </dl>
689
690 <p>The function `est_node_put_doc' is used in order to add a document to a node.</p>
691
692 <dl>
693 <dt><kbd>int est_node_put_doc(ESTNODE *<var>node</var>, ESTDOC *<var>doc</var>);</kbd></dt>
694 <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>
695 </dl>
696
697 <p>The function `est_node_out_doc' is used in order to remove a document from a node.</p>
698
699 <dl>
700 <dt><kbd>int est_node_out_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
701 <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>
702 </dl>
703
704 <p>The function `est_node_out_doc_by_uri' is used in order to remove a document specified by URI from a node.</p>
705
706 <dl>
707 <dt><kbd>int est_node_out_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
708 <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>
709 </dl>
710
711 <p>The function `est_node_get_doc' is used in order to retrieve a document in a node.</p>
712
713 <dl>
714 <dt><kbd>ESTDOC *est_node_get_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
715 <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>
716 </dl>
717
718 <p>The function `est_node_get_doc_by_uri' is used in order to retrieve a document specified by URI in a node.</p>
719
720 <dl>
721 <dt><kbd>ESTDOC *est_node_get_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
722 <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>
723 </dl>
724
725 <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>
726
727 <dl>
728 <dt><kbd>char *est_node_get_doc_attr(ESTNODE *<var>node</var>, int <var>id</var>, const char *<var>name</var>);</kbd></dt>
729 <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>
730 </dl>
731
732 <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>
733
734 <dl>
735 <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>
736 <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>
737 </dl>
738
739 <p>The function `est_node_uri_to_id' is used in order to get the ID of a document spacified by URI.</p>
740
741 <dl>
742 <dt><kbd>int est_node_uri_to_id(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
743 <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>
744 </dl>
745
746 <p>The function `est_node_name' is used in order to get the name of a node.</p>
747
748 <dl>
749 <dt><kbd>const char *est_node_name(ESTNODE *<var>node</var>);</kbd></dt>
750 <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>
751 </dl>
752
753 <p>The function `est_node_label' is used in order to get the label of a node.</p>
754
755 <dl>
756 <dt><kbd>const char *est_node_label(ESTNODE *<var>node</var>);</kbd></dt>
757 <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>
758 </dl>
759
760 <p>The function `est_node_doc_num' is used in order to get the number of documents in a node.</p>
761
762 <dl>
763 <dt><kbd>int est_node_doc_num(ESTNODE *<var>node</var>);</kbd></dt>
764 <dd>`node' specifies a node connection object. The return value is the number of documents in the node. On error, -1 is returned.</dd>
765 </dl>
766
767 <p>The function `est_node_word_num' is used in order to get the number of unique words in a node.</p>
768
769 <dl>
770 <dt><kbd>int est_node_word_num(ESTNODE *<var>node</var>);</kbd></dt>
771 <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>
772 </dl>
773
774 <p>The function `est_node_size' is used in order to get the size of the datbase of a node.</p>
775
776 <dl>
777 <dt><kbd>double est_node_size(ESTNODE *<var>node</var>);</kbd></dt>
778 <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>
779 </dl>
780
781 <p>The function `est_node_search' is used in order to search documents corresponding a condition for a node.</p>
782
783 <dl>
784 <dt><kbd>ESTNODERES *est_node_search(ESTNODE *<var>node</var>, ESTCOND *<var>cond</var>, int <var>depth</var>);</kbd></dt>
785 <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>
786 </dl>
787
788 <p>The function `est_node_set_user' is used in order to manage a user account of a node.</p>
789
790 <dl>
791 <dt><kbd>int est_node_set_user(ESTNODE *<var>node</var>, const char *<var>name</var>, int <var>mode</var>);</kbd></dt>
792 <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>
793 </dl>
794
795 <p>The function `est_node_set_link' is used in order to manage a link of a node.</p>
796
797 <dl>
798 <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>
799 <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>
800 </dl>
801
802 <h3>API for Search Results of Nodes</h3>
803
804 <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>
805
806 <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>
807
808 <p>The following is a typical use case of node connection object and result document object.</p>
809
810 <pre>ESTNODERES *nres;
811 CBMAP *hints;
812 ESTRESDOC *rdoc;
813 int i;
814
815 /* create a node result object */
816 nres = est_node_search(node, cond, 1);
817
818 /* get hints */
819 hints = est_noderes_hints(nres);
820
821 /* show the hints here */
822
823 /* scan documents in the result */
824 for(i = 0; i &lt; est_noderes_doc_num(nres); i++){
825
826 /* get a result document object */
827 rdoc = est_noderes_get_doc(nres, i);
828
829 /* show the result document object here */
830
831 }
832
833 /* destroy the node result object */
834 est_noderes_delete(nres);
835 </pre>
836
837 <p>The function `est_noderes_delete' is used in order to delete a node result object.</p>
838
839 <dl>
840 <dt><kbd>void est_noderes_delete(ESTNODERES *<var>nres</var>);</kbd></dt>
841 <dd>`nres' specifies a node result object.</dd>
842 </dl>
843
844 <p>The function `est_noderes_hints' is used in order to get a map object for hints of a node result object.</p>
845
846 <dl>
847 <dt><kbd>CBMAP *est_noderes_hints(ESTNODERES *<var>nres</var>);</kbd></dt>
848 <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>
849 </dl>
850
851 <p>The function `est_noderes_doc_num' is used in order to get the number of documents in a node result object.</p>
852
853 <dl>
854 <dt><kbd>int est_noderes_doc_num(ESTNODERES *<var>nres</var>);</kbd></dt>
855 <dd>`nres' specifies a node result object. The return value is the number of documents in a node result object.</dd>
856 </dl>
857
858 <p>The function `est_noderes_get_doc' is used in order to refer a result document object in a node result object.</p>
859
860 <dl>
861 <dt><kbd>ESTRESDOC *est_noderes_get_doc(ESTNODERES *<var>nres</var>, int <var>index</var>);</kbd></dt>
862 <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>
863 </dl>
864
865 <p>The function `est_resdoc_uri' is used in order to get the URI of a result document object.</p>
866
867 <dl>
868 <dt><kbd>const char *est_resdoc_uri(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
869 <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>
870 </dl>
871
872 <p>The function `est_resdoc_attr_names' is used in order to get a list of attribute names of a result document object.</p>
873
874 <dl>
875 <dt><kbd>CBLIST *est_resdoc_attr_names(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
876 <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>
877 </dl>
878
879 <p>The function `est_resdoc_attr' is used in order to get the value of an attribute of a result document object.</p>
880
881 <dl>
882 <dt><kbd>const char *est_resdoc_attr(ESTRESDOC *<var>rdoc</var>, const char *<var>name</var>);</kbd></dt>
883 <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>
884 </dl>
885
886 <p>The function `est_resdoc_snippet' is used in order to get the snippet of a result document object.</p>
887
888 <dl>
889 <dt><kbd>const char *est_resdoc_snippet(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
890 <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>
891 </dl>
892
893 <h3>Paralleling</h3>
894
895 <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>
896
897 <hr />
898
899 <h2 id="estcall">Command of a Client</h2>
900
901 <p>`estcall' is provided as a client command to manage the node server. This section describes how to use estcall.</p>
902
903 <h3>Synopsis and Description</h3>
904
905 <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>
906
907 <dl>
908 <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>
909 <dd>Register a document of document draft to a node.</dd>
910 <dd><var>file</var> specifies a target file. If it is omitted, the standard input is read.</dd>
911 </dl>
912
913 <dl>
914 <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>
915 <dd>Remove information of a document from a node.</dd>
916 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
917 </dl>
918
919 <dl>
920 <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>
921 <dd>Output document draft of a document in a node.</dd>
922 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
923 <dd>If <var>attr</var> is specified, only the value of the attribute is output.</dd>
924 </dl>
925
926 <dl>
927 <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>
928 <dd>Output the ID number of a document specified by URI.</dd>
929 <dd><var>uri</var> specifies the URI of a document.</dd>
930 </dl>
931
932 <dl>
933 <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>
934 <dd>Outout the name, the label, the number of documents, and the number of unique words of a node.</dd>
935 </dl>
936
937 <dl>
938 <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>
939 <dd>Search a node for documents.</dd>
940 <dd><var>phrase</var> specifies the search phrase.</dd>
941 <dd>If -vx is specified, XML including including attributes and snippets is output.</dd>
942 <dd>-attr specifies an attribute search condition. This option can be specified multiple times.</dd>
943 <dd>-ord specifies the order expression. By default, it is descending by score.</dd>
944 <dd>-max specifies the maximum number of show documents. Negative means unlimited. By default, it is 10.</dd>
945 <dd>-dpt specifies depth of meta search. by default it is 0.</dd>
946 </dl>
947
948 <dl>
949 <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>
950 <dd>Set permission of a user.</dd>
951 <dd><var>name</var> specifies the name of a user.</dd>
952 <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>
953 </dl>
954
955 <dl>
956 <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>
957 <dd>Set a link to another node.</dd>
958 <dd><var>url</var> specifies the URL of a destination node.</dd>
959 <dd><var>label</var> specifies the label of the link.</dd>
960 <dd><var>credit</var> specifies the credit of the link. If the value is negative, the link is removed.</dd>
961 </dl>
962
963 <dl>
964 <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>
965 <dd>Outout response of an HTTP request.</dd>
966 <dd><var>url</var> specifies the URL of a target.</dd>
967 <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>
968 <dd>If -np is specified, output response headers also.</dd>
969 <dd>-eh specifies an additional HTTP header. By default, "Host", "Connection", "User-Agent", and "Content-Length" is added.</dd>
970 </dl>
971
972 <p>All sub commands return 0 if the operation is success, else return 1.</p>
973
974 <h3>Examples</h3>
975
976 <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>
977
978 <pre>estcall raw -auth admin admin \
979 'http://localhost:1978/master?action=shutdown'
980 </pre>
981
982 <p>In order to add a user, perform the following command.</p>
983
984 <pre>estcall raw -auth admin admin \
985 'http://localhost:1978/master?action=useradd&amp;name=mikio&amp;passwd=iloveyou'
986 </pre>
987
988 <p>In order to use POST method, perform the following command.</p>
989
990 <pre>echo -n 'action=useradd&amp;name=mikio&amp;passwd=iloveyou' |
991 estcall raw -auth admin admin \
992 -eh 'Content-Type: application/x-www-form-urlencoded' \
993 'http://localhost:1978/master' -
994 </pre>
995
996 <hr />
997
998 </body>
999
1000 </html>
1001
1002 <!-- END OF FILE -->

  ViewVC Help
Powered by ViewVC 1.1.26