/[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 5 - (show annotations)
Sat Jul 30 12:03:41 2005 UTC (18 years, 9 months ago) by dpavlin
File MIME type: text/html
File size: 55591 byte(s)
finished architecture

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

  ViewVC Help
Powered by ViewVC 1.1.26