/[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 6 - (show annotations)
Sat Jul 30 18:32:07 2005 UTC (18 years, 10 months ago) by dpavlin
File MIME type: text/html
File size: 55830 byte(s)
updated document up to search

1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
7 <head>
8 <meta http-equiv="Content-Language" content="en" />
9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
10 <meta http-equiv="Content-Style-Type" content="text/css" />
11 <meta name="author" content="Mikio Hirabayashi" />
12 <meta name="keywords" content="Hyper Estraier, Estraier, full-text search, API, Node, P2P" />
13 <meta name="description" content="API specifications of Hyper Estraier" />
14 <link rel="contents" href="./" />
15 <link rel="alternate" href="nguide-ja.html" hreflang="ja" title="the Japanese version" />
16 <link rel="stylesheet" href="common.css" />
17 <link rel="icon" href="icon16.png" />
18 <link rev="made" href="mailto:mikio@users.sourceforge.net" />
19 <title>P2P Guide of Hyper Estraier Version 1.1</title>
20 </head>
21
22 <body>
23
24 <h1>P2P Guide</h1>
25
26 <div class="note">Copyright (C) 2004-2005 Mikio Hirabayashi</div>
27 <div class="note">Last Update: Tue, 07 Jun 2005 06:17:00 +0900</div>
28 <div class="navi">[<a href="nguide-ja.html" hreflang="ja">Japanese</a>] [<a href="index.html">HOME</a>]</div>
29
30 <hr />
31
32 <h2 id="tableofcontents">Table of Contents</h2>
33
34 <ol>
35 <li><a href="#introduction">Introduction</a></li>
36 <li><a href="#architecture">Architecture</a></li>
37 <li><a href="#tutorial">Tutorial</a></li>
38 <li><a href="#estmaster">Command of the Node Master</a></li>
39 <li><a href="#protocol">Protocol</a></li>
40 <li><a href="#nodeapi">Node API</a></li>
41 <li><a href="#estcall">Command of a Client</a></li>
42 </ol>
43
44 <hr />
45
46 <h2 id="introduction">Introduction</h2>
47
48 <p>This document describes 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 <tt>estcmd</tt> 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. <tt>estmaster</tt> 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 unidirectional 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>Concept of P2P seems difficult at first, so it's best to start with a
165 tutorial which will show commands used to setup search network.</p>
166
167 <h3>Start and Stop</h3>
168
169 <p>First step is creation of <em>node master</em> directory which contains
170 configuration files and indexes. Following command will create
171 <tt>casket</tt> root server directory:</p>
172
173 <pre>estmaster init casket
174 </pre>
175
176 <p>Next, we need to start <em>node master</em> using:</p>
177
178 <pre>estmaster start casket
179 </pre>
180
181 <p>To stop <em>node master</em> you can press CTRL+C on terminal in which it's running on issue following command:</p>
182
183 <pre>estmaster stop casket
184 </pre>
185
186 <h3>Administration Interface</h3>
187
188 <p>After starting <em>node master</em> you can access it's administration
189 interface pointing web browser at
190 <a href="http://localhost:1978/masterui">http://localhost:1978/masterui</a>.
191 This will bring HTTP authorization dialog requesting user name and password.
192 Enter <em>admin</em> and <em>admin</em>. You will be presented with
193 administration commands menu.
194 </p>
195
196 <p>First option is <em>Manage Master</em> which provides option to shutdown
197 <em>node master</em>. However, let's leave it running for now.</p>
198
199 <p>Since you are logged as <em>admin</em> which has super user privileges,
200 we can edit users. We will create new account with super user privileges
201 and switch to it. We will also erase <em>admin</em> user because it has
202 well-known password and it's possible security hole.
203 </p>
204
205 <p>Select <em>Manage Users</em>. There are input boxes for user name,
206 password, flags, full name and miscellaneous information at bottom. Enter
207 following data for new user:
208 <em>clint</em>, <em>tnilc</em>, <em>s</em>, <em>Clint Eastwood</em> and
209 <em>Dirty Harry</em>. Flag <em>s</em> denotes user with super user
210 privileges. User name is limited to alphanumeric characters only.
211 </p>
212
213 <p>You can now delete <em>admin</em> user using <em>DELE</em> link and confirm that by clicking on <em>delete</em> button.</p>
214
215 <p>Select <em>Manage Nodes</em> next. Since we just erased <em>admin</em>
216 user, you will be again asked for user name and password. Enter
217 <em>client</em> and <em>tnilc</em> to login again.
218 <br/>
219 Input boxes at bottom allows you to enter new index name and label. Index
220 name is limited to alphanumeric characters only. Enter <em>test1</em> as name
221 and <em>First Node</em> as description. Create another node with
222 <em>test2</em> name and <em>Second Node</em> as description.
223 </p>
224
225 <h3>Register Documents</h3>
226
227 <p>We'll now register new document in index. For that, we will use terminal
228 window again. Since terminal in which you started <tt>estmaster</tt> is busy
229 outputting log messages, open another one.
230 </p>
231
232 <p>Documents which are about to be registered in index must be in draft data
233 format. Create file <tt>data001.est</tt> with following content:
234 </p>
235
236 <pre>@uri=data001
237 @title=Material Girl
238
239 Living in a material world
240 And I am a material girl
241 You know that we are living in a material world
242 And I am a material girl
243 </pre>
244
245 <p>We are going to register this document to node <em>test1</em>. Since updating of index needs super user permission, we will use <tt>-auth</tt> option to specify user name and password for our newly created user.</p>
246
247 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test1 data001.est
248 </pre>
249
250 <p>Document registration will finish shortly, and absence of any error message denotes that it has been successful.</p>
251
252 <p>To demonstrate meta search mentioned before, we will register another
253 document to node <em>test2</em>. Create file <tt>data002.est</tt> with
254 following content:
255 </p>
256
257 <pre>@uri=data002
258 @title=Liberian Girl
259
260 Liberian girl
261 You came and you changed My world
262 A love so brand new
263 </pre>
264
265 <p>Then, register document using:</p>
266
267 <pre>estcall put -auth clint tnilc http://localhost:1978/node/test2 data002.est
268 </pre>
269
270 <p>As you can see, it's possible to register documents from any machine
271 connected to network on which <tt>estmaster</tt> is running. You can
272 register few additional documents if you want now.</p>
273
274 <h3>Search for Documents</h3>
275
276 <p>All right, let's search for some registered documents. Perform the following command, and information of the corresponding document is shown.</p>
277
278 <pre>estcall search http://localhost:1978/node/test1 "material world"
279 </pre>
280
281 <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>
282
283 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
284 http://localhost:1978/node/test2 TEST02 8000
285 </pre>
286
287 <p>And, search again. This time, set depth of meta search with the option -dpt.</p>
288
289 <pre>estcall search -dpt 1 http://localhost:1978/node/test1 "girl"
290 </pre>
291
292 <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>
293
294 <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>
295
296 <pre>estcall setlink -auth clint tnilc http://localhost:1978/node/test1 \
297 http://localhost:1978/node/test2 TEST02 12000
298 </pre>
299
300 <p>You can get result as XML data. Perform the following command. See estresult.dtd for detail of the XML format.</p>
301
302 <pre>estcall search -dpt 1 -vx http://localhost:1978/node/test1 "girl"
303 </pre>
304
305 <p>Each node server embeds search interface for web browsers. Access "http://localhost:1978/node/test1/searchui" to use it.</p>
306
307 <hr />
308
309 <h2 id="estmaster">Command of the Node Master</h2>
310
311 <p>`estmaster' is provided as a command to manage the node master. This section describes how to use estmaster.</p>
312
313 <h3>Synopsis and Description</h3>
314
315 <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>
316
317 <dl>
318 <dt><kbd>estmaster init [-ex] <var>rootdir</var></kbd></dt>
319 <dd>Create the server root directory.</dd>
320 <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>
321 </dl>
322
323 <dl>
324 <dt><kbd>estmaster start [-bg] [-st] <var>rootdir</var></kbd></dt>
325 <dd>Start the node master.</dd>
326 <dd>If -bg is specified, the server runs in background as a daemon process.</dd>
327 <dd>If -st is specified, the server runs in single thread mode.</dd>
328 </dl>
329
330 <dl>
331 <dt><kbd>estmaster stop <var>rootdir</var></kbd></dt>
332 <dd>Stop the running node master.</dd>
333 </dl>
334
335 <dl>
336 <dt><kbd>estmaster unittest <var>rootdir</var></kbd></dt>
337 <dd>Perform unit tests.</dd>
338 </dl>
339
340 <dl>
341 <dt><kbd>estmaster crypt <var>key</var> [<var>hash</var>]</kbd></dt>
342 <dd>Output an encrypted string of a string.</dd>
343 <dd><var>key</var> specifies a target string.</dd>
344 <dd>If <var>hash</var> is specified, it checks whether the key and the hash matches.</dd>
345 </dl>
346
347 <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>
348
349 <p>A running node server sould be finished by valid means by command line or via network. Otherwise, the index may be broken.</p>
350
351 <h3>Constitution of the Server Root Directory</h3>
352
353 <p>The server root directory contains the following files and directories.</p>
354
355 <ul>
356 <li><kbd>_conf</kbd> : prime configuration file.</li>
357 <li><kbd>_user</kbd> : user account file.</li>
358 <li><kbd>_log</kbd> : log file.</li>
359 <li><kbd>_meta</kbd> : database file for meta data.</li>
360 <li><kbd>_pid</kbd> : file recording the process ID.</li>
361 <li><kbd>_stop</kbd> : file to stop the node master.</li>
362 <li><kbd>_node/</kbd> : node directory.</li>
363 <li><kbd>_sess/</kbd> : session directory.</li>
364 </ul>
365
366 <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>
367
368 <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>
369
370 <h3>Prime Configuration File</h3>
371
372 <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>
373
374 <pre>hostname: localhost
375 portnum: 1978
376 runmode: 1
377 authmode: 2
378 maxconn: 30
379 sessiontimeout: 600
380 searchtimeout: 8
381 searchdepth: 5
382 proxyhost:
383 proxyport:
384 loglevel: 2
385 docroot:
386 indexfile:
387 trustednodes:
388 denyuntrusted: 0
389 cachesize: 64
390 specialcache:
391 snipwwidth: 480
392 sniphwidth: 96
393 snipawidth: 96
394 </pre>
395
396 <p>Means of each variable is the following.</p>
397
398 <ul>
399 <li><kbd>hostname</kbd> : specifies the host name of the server.</li>
400 <li><kbd>portnum</kbd> : specifies the port number of the server.</li>
401 <li><kbd>runmode</kbd> : specifies running mode (1:normal, 2:readonly).</li>
402 <li><kbd>authmode</kbd> : specifies authorization mode (1:none, 2:admin, 3:all).</li>
403 <li><kbd>maxconn</kbd> : specifies maximum number of connections at the same time.</li>
404 <li><kbd>sessiontimeout</kbd> : specifies timeout of a session (in seconds).</li>
405 <li><kbd>searchtimeout</kbd> : specifies timeout of search (in seconds).</li>
406 <li><kbd>searchdepth</kbd> : specifies maximum depth of meta search.</li>
407 <li><kbd>proxyhost</kbd> : specifies the host name of the proxy server.</li>
408 <li><kbd>proxyport</kbd> : specifies the port number of the proxy server.</li>
409 <li><kbd>loglevel</kbd> : specifies logging level (1:debug, 2:information, 3:warning, 4:error, 5:none).</li>
410 <li><kbd>docroot</kbd> : specifies document root directory (full path of a directory to be public).</li>
411 <li><kbd>indexfile</kbd> : specifies index file (name of directory index files).</li>
412 <li><kbd>trustednodes</kbd> : specifies decimal IP addresses of trusted nodes (list separated by comma).</li>
413 <li><kbd>denyuntrusted</kbd> : specifies whether to deny all nodes except for trusted nodes (0:no, 1:yes).</li>
414 <li><kbd>cachesize</kbd> : specifies maximum size of the index cache (in mega bytes).</li>
415 <li><kbd>specialcache</kbd> : specifies name of the attribute of the special cache.</li>
416 <li><kbd>snipwwidth</kbd> : specifies whole width of the snippet of each shown document.</li>
417 <li><kbd>sniphwidth</kbd> : specifies width of strings picked up from the beginning of the text.</li>
418 <li><kbd>snipawidth</kbd> : specifies width of strings picked up around each highlighted word.</li>
419 </ul>
420
421 <h3>User Account File</h3>
422
423 <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>
424
425 <pre>admin 21232f297a57a5a743894a0e4a801fc3 s Carolus Magnus Administrator
426 </pre>
427
428 <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>
429
430 <h3>Embedded User Interfaces</h3>
431
432 <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>
433
434 <p>By accessing the URL which is the URL of a node server followed by "/searchui", you can use the search interface.</p>
435
436 <hr />
437
438 <h2 id="protocol">Protocol</h2>
439
440 <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>
441
442 <h3>Introduction</h3>
443
444 <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>
445
446 <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>
447
448 <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>
449
450 <ul>
451 <li>400 : parameters are invalid.</li>
452 <li>401 : authority information lacks or is invalid.</li>
453 <li>403 : the account has not the permission.</li>
454 <li>404 : the node does not exist.</li>
455 <li>500 : some errors of due to the server occurred.</li>
456 </ul>
457
458 <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>
459
460 <h3>Operation of Node Master</h3>
461
462 <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>
463
464 <dl>
465 <dt><kbd>/master?action=shutdown</kbd></dt>
466 <dd>Shutdown the node master.</dd>
467 <dd>No parameter is used.</dd>
468 <dd>On success, the status code 202 is returned.</dd>
469 </dl>
470
471 <dl>
472 <dt><kbd>/master?action=userlist</kbd></dt>
473 <dd>Get the list of user accounts.</dd>
474 <dd>No parameter is used.</dd>
475 <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>
476 </dl>
477
478 <dl>
479 <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>
480 <dd>Add a user account.</dd>
481 <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>
482 <dd><var>passwd</var> specifies the password. It is essantial.</dd>
483 <dd><var>flags</var> specifies the flags. It is optional.</dd>
484 <dd><var>fname</var> specifies the full name. It is optional.</dd>
485 <dd><var>misc</var> specifies the miscellaneous information. It is optional.</dd>
486 <dd>On success, the status code 200 is returned.</dd>
487 <dd>Because the password is sent, POST method should be used.</dd>
488 </dl>
489
490 <dl>
491 <dt><kbd>/master?action=userdel&amp;name=<var>str</var></kbd></dt>
492 <dd>Delete a user account.</dd>
493 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
494 <dd>On success, the status code 200 is returned.</dd>
495 </dl>
496
497 <dl>
498 <dt><kbd>/master?action=nodelist</kbd></dt>
499 <dd>Get the list of node servers.</dd>
500 <dd>No parameter is used.</dd>
501 <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>
502 </dl>
503
504 <dl>
505 <dt><kbd>/master?action=nodeadd&amp;name=<var>str</var>&amp;label=<var>str</var></kbd></dt>
506 <dd>Add a node server.</dd>
507 <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>
508 <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>
509 <dd>On success, the status code 200 is returned.</dd>
510 </dl>
511
512 <dl>
513 <dt><kbd>/master?action=nodedel&amp;name=<var>str</var></kbd></dt>
514 <dd>Delete a node server.</dd>
515 <dd><var>name</var> specifies the name of a node. It is essential.</dd>
516 <dd>On success, the status code 200 is returned.</dd>
517 </dl>
518
519 <h3>Operation of Node Server</h3>
520
521 <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>
522
523 <dl>
524 <dt><kbd>/node/<var>name</var>/inform</kbd></dt>
525 <dd>Get information of a node.</dd>
526 <dd>No parameter is used.</dd>
527 <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>
528 </dl>
529
530 <dl>
531 <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>
532 <dd>Search for documents.</dd>
533 <dd><var>phrase</var> specifies the search phrase. It is optional. The format is as with the one of the core API.</dd>
534 <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>
535 <dd><var>order</var> specifies the order expression. It is optional. The format is as with the one of the core API.</dd>
536 <dd><var>max</var> specifies the maximum number of shown documents. It is optional. By default, it is 10.</dd>
537 <dd><var>options</var> specifies options. It is optional. The value is as with the one of the core API.</dd>
538 <dd><var>depth</var> specifies depth of meta search. It is optional. By default, it is 0.</dd>
539 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is explained later.</dd>
540 </dl>
541
542 <dl>
543 <dt><kbd>/node/<var>name</var>/get_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
544 <dd>Get information of a document.</dd>
545 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
546 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
547 <dd>On success, the status code 200 is returned. The entity body of response expresses the search result. The format is document draft.</dd>
548 </dl>
549
550 <dl>
551 <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>
552 <dd>Get the value of an attribute of a document.</dd>
553 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
554 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
555 <dd><var>attr</var> specifies the name of an attribute. It is essential.</dd>
556 <dd>On success, the status code 200 is returned. The entity body of response expresses the value of the attribute.</dd>
557 </dl>
558
559 <dl>
560 <dt><kbd>/node/<var>name</var>/uri_to_id?uri=<var>str</var></kbd></dt>
561 <dd>Get the ID number of a document specified by URI.</dd>
562 <dd><var>uri</var> specifies the URI of a document. It is essential.</dd>
563 <dd>On success, the status code 200 is returned. The entity body of response expresses the ID number of the document.</dd>
564 </dl>
565
566 <dl>
567 <dt><kbd>/node/<var>name</var>/put_doc?draft=<var>str</var></kbd></dt>
568 <dd>Register a docuemnt. It is available by administrators only.</dd>
569 <dd><var>draft</var> specifies content of a document in document draft format. It is essential.</dd>
570 <dd>On success, the status code 200 is returned.</dd>
571 </dl>
572
573 <dl>
574 <dt><kbd>/node/<var>name</var>/out_doc?id=<var>num</var>&amp;uri=<var>str</var></kbd></dt>
575 <dd>Remove a document. It is available by administrators only.</dd>
576 <dd><var>id</var> specifies the ID number of a document. It is optional.</dd>
577 <dd><var>uri</var> specifies the URI of a document. It is optional.</dd>
578 <dd>On success, the status code 200 is returned.</dd>
579 </dl>
580
581 <dl>
582 <dt><kbd>/node/<var>name</var>/_set_user?name=<var>str</var>&amp;mode=<var>num</var></kbd></dt>
583 <dd>Set permission of a user. It is available by administrators only.</dd>
584 <dd><var>name</var> specifies the name of a user. It is essential.</dd>
585 <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>
586 <dd>On success, the status code 200 is returned.</dd>
587 </dl>
588
589 <dl>
590 <dt><kbd>/node/<var>name</var>/_set_link?url=<var>str</var>&amp;label=<var>str</var>&amp;credit=<var>num</var></kbd></dt>
591 <dd>Set a link to another node. It is available by administrators only.</dd>
592 <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>
593 <dd><var>label</var> specifies the label of the link. It is essential.</dd>
594 <dd><var>credit</var> specifies the credit of the link. It is optional. If it is omitted, the link is removed.</dd>
595 <dd>On success, the status code 200 is returned.</dd>
596 </dl>
597
598 <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>
599
600 <h3>Format of Search Result</h3>
601
602 <p>The format of the entitiy body of result of search command is alike to multipart of MIME. The following is an example.</p>
603
604 <pre>--------[2387AD2E34554FFF]--------
605 VERSION 0.9
606 NODE http://localhost:1978/node/sample1
607 HIT 2
608 HINT#1 give 2
609 DOCNUM 2
610 WORDNUM 31
611 TIME 0.001
612 LINK#0 http://localhost:1978/node/sample1 Sample1 10000 2 31 2731304 2
613 LINK#1 http://localhost:1978/node/sample2 Sample2 4000 3 125 8524522 1
614 VIEW SNIPPET
615
616 --------[2387AD2E34554FFF]--------
617 #nodelabel=Sample Node One
618 #nodeurl=http://localhost:1978/node/sample1
619 @id=1
620 @uri=http://localhost/foo.html
621
622 You may my glories and my state dispose, But not my griefs; still am I king of those. (
623 Give give
624 it u
625
626 p, Yo!
627 Give give
628 it up, Yo!)
629
630 --------[2387AD2E34554FFF]--------
631 #nodelabel=Sample Node One
632 #nodeurl=http://localhost:1978/node/sample1
633 @id=2
634 @uri=http://localhost/bar.html
635
636 The faster I go, the behinder I get. (
637 Give give
638 it up, Yo!
639 Give give
640 it up, Yo!)
641
642 --------[2387AD2E34554FFF]--------:END
643 </pre>
644
645 <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>
646
647 <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>
648
649 <ul>
650 <li><kbd>VERSION</kbd> : specifies the version of the protocol.</li>
651 <li><kbd>NODE</kbd> : specifies the URL of the node.</li>
652 <li><kbd>HIT</kbd> : specifies the total number of the corresponding documents.</li>
653 <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>
654 <li><kbd>DOCNUM</kbd> : specifies the total number of documents in target nodes.</li>
655 <li><kbd>WORDNUM</kbd> : specifies the total number of words in target nodes.</li>
656 <li><kbd>TIME</kbd> : specifies elapsed time in milliseconds.</li>
657 <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>
658 <li><kbd>VIEW</kbd> : specifies the format of document parts. As for now, it is constantly "SNIPPET".</li>
659 </ul>
660
661 <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>
662
663 <p>The following pseudo-attributes are added to each result documents of the search command or the get_doc command includes.</p>
664
665 <ul>
666 <li><kbd>#nodeurl</kbd> : specifies the URL of the node into which the document was registered.</li>
667 <li><kbd>#nodelabel</kbd> : specifies the label of the node into which the document was registered.</li>
668 </ul>
669
670 <h3>Special Format for Document Registration</h3>
671
672 <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>
673
674 <pre>POST /node/foo/put_doc HTTP/1.0
675 Content-Type: text/x-estraier-draft
676 Content-Length: 138
677
678 @uri=http://gogo.estraier.go.jp/sample.html
679 @title=Twinkle Twinkle Little Star
680
681 Twinkle, twinkle, little star,
682 How I wonder what you are.
683 </pre>
684
685 <hr />
686
687 <h2 id="nodeapi">Node API</h2>
688
689 <p>As it is a bother to implement HTTP, the node API is useful. This section describes how to use the node API.</p>
690
691 <h3>Introduction</h3>
692
693 <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>
694
695 <p>In each source of applications of the node API, include `estraier.h', `estnode.h', `cabin.h', and `stdlib.h'.</p>
696
697 <pre>#include &lt;estraier.h&gt;
698 #include &lt;estnode.h&gt;
699 #include &lt;cabin.h&gt;
700 #include &lt;stdlib.h&gt;
701 </pre>
702
703 <p>To build an application, perform the following command. It is same as with the core API.</p>
704
705 <pre>gcc `estconfig --cflags` -o foobar foobar.c `estconfig --ldflags` `estconfig --libs`
706 </pre>
707
708 <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>
709
710 <h3>API for Initializing</h3>
711
712 <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>
713
714 <p>The function `est_init_net_env' is used in order to initialize the networking environment.</p>
715
716 <dl>
717 <dt><kbd>int est_init_net_env(void);</kbd></dt>
718 <dd>The return value is true if success, else it is false.</dd>
719 </dl>
720
721 <p>The function `est_free_net_env' is used in order to free the networking environment.</p>
722
723 <dl>
724 <dt><kbd>void est_free_net_env(void);</kbd></dt>
725 <dd>There is no parameter and no return value.</dd>
726 </dl>
727
728 <h3>API for Nodes</h3>
729
730 <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>
731
732 <p>The following is a typical use case of node connection object.</p>
733
734 <pre>ESTNODE *node;
735
736 /* create a node connection object */
737 node = est_node_new("http://estraier.gov:1978/node/foo");
738
739 /* set the proxy, the timeout, and the autority */
740 est_node_set_proxy(node, "proxy.qdbm.go.jp", 8080);
741 est_node_set_timeout(node, 5);
742 est_node_set_auth(node, "mikio", "oikim");
743
744 /* register documents or search for documents here */
745
746 /* destroy the object */
747 est_node_delete(node);
748 </pre>
749
750 <p>The function `est_node_new' is used in order to create a node connection object.</p>
751
752 <dl>
753 <dt><kbd>ESTNODE *est_node_new(const char *<var>url</var>);</kbd></dt>
754 <dd>`url' specifies the URL of a node. The return value is a node connection object.</dd>
755 </dl>
756
757 <p>The function `est_node_delete' is used in order to destroy a node connection object.</p>
758
759 <dl>
760 <dt><kbd>void est_node_delete(ESTNODE *<var>node</var>);</kbd></dt>
761 <dd>`node' specifies a node connection object.</dd>
762 </dl>
763
764 <p>The function `est_node_status' is used in order to get the status code of the last request of a node.</p>
765
766 <dl>
767 <dt><kbd>int est_node_status(ESTNODE *<var>node</var>);</kbd></dt>
768 <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>
769 </dl>
770
771 <p>The function `est_node_set_proxy' is used in order to set the proxy information of a node connection object.</p>
772
773 <dl>
774 <dt><kbd>void est_node_set_proxy(ESTNODE *<var>node</var>, const char *<var>host</var>, int <var>port</var>);</kbd></dt>
775 <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>
776 </dl>
777
778 <p>The function `est_node_set_timeout' is used in order to set timeout of a connection.</p>
779
780 <dl>
781 <dt><kbd>void est_node_set_timeout(ESTNODE *<var>node</var>, int <var>sec</var>);</kbd></dt>
782 <dd>`node' specifies a node connection object. `sec' specifies timeout of the connection in seconds.</dd>
783 </dl>
784
785 <p>The function `est_node_set_auth' is used in order to set the authoririty information of a node connection object.</p>
786
787 <dl>
788 <dt><kbd>void est_node_set_auth(ESTNODE *<var>node</var>, const char *<var>name</var>, const char *<var>passwd</var>);</kbd></dt>
789 <dd>`node' specifies a node connection object. `name' specifies the name of an authority. `passwd' specifies the password of the authority.</dd>
790 </dl>
791
792 <p>The function `est_node_put_doc' is used in order to add a document to a node.</p>
793
794 <dl>
795 <dt><kbd>int est_node_put_doc(ESTNODE *<var>node</var>, ESTDOC *<var>doc</var>);</kbd></dt>
796 <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>
797 </dl>
798
799 <p>The function `est_node_out_doc' is used in order to remove a document from a node.</p>
800
801 <dl>
802 <dt><kbd>int est_node_out_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
803 <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>
804 </dl>
805
806 <p>The function `est_node_out_doc_by_uri' is used in order to remove a document specified by URI from a node.</p>
807
808 <dl>
809 <dt><kbd>int est_node_out_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
810 <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>
811 </dl>
812
813 <p>The function `est_node_get_doc' is used in order to retrieve a document in a node.</p>
814
815 <dl>
816 <dt><kbd>ESTDOC *est_node_get_doc(ESTNODE *<var>node</var>, int <var>id</var>);</kbd></dt>
817 <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>
818 </dl>
819
820 <p>The function `est_node_get_doc_by_uri' is used in order to retrieve a document specified by URI in a node.</p>
821
822 <dl>
823 <dt><kbd>ESTDOC *est_node_get_doc_by_uri(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
824 <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>
825 </dl>
826
827 <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>
828
829 <dl>
830 <dt><kbd>char *est_node_get_doc_attr(ESTNODE *<var>node</var>, int <var>id</var>, const char *<var>name</var>);</kbd></dt>
831 <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>
832 </dl>
833
834 <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>
835
836 <dl>
837 <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>
838 <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>
839 </dl>
840
841 <p>The function `est_node_uri_to_id' is used in order to get the ID of a document spacified by URI.</p>
842
843 <dl>
844 <dt><kbd>int est_node_uri_to_id(ESTNODE *<var>node</var>, const char *<var>uri</var>);</kbd></dt>
845 <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>
846 </dl>
847
848 <p>The function `est_node_name' is used in order to get the name of a node.</p>
849
850 <dl>
851 <dt><kbd>const char *est_node_name(ESTNODE *<var>node</var>);</kbd></dt>
852 <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>
853 </dl>
854
855 <p>The function `est_node_label' is used in order to get the label of a node.</p>
856
857 <dl>
858 <dt><kbd>const char *est_node_label(ESTNODE *<var>node</var>);</kbd></dt>
859 <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>
860 </dl>
861
862 <p>The function `est_node_doc_num' is used in order to get the number of documents in a node.</p>
863
864 <dl>
865 <dt><kbd>int est_node_doc_num(ESTNODE *<var>node</var>);</kbd></dt>
866 <dd>`node' specifies a node connection object. The return value is the number of documents in the node. On error, -1 is returned.</dd>
867 </dl>
868
869 <p>The function `est_node_word_num' is used in order to get the number of unique words in a node.</p>
870
871 <dl>
872 <dt><kbd>int est_node_word_num(ESTNODE *<var>node</var>);</kbd></dt>
873 <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>
874 </dl>
875
876 <p>The function `est_node_size' is used in order to get the size of the datbase of a node.</p>
877
878 <dl>
879 <dt><kbd>double est_node_size(ESTNODE *<var>node</var>);</kbd></dt>
880 <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>
881 </dl>
882
883 <p>The function `est_node_search' is used in order to search documents corresponding a condition for a node.</p>
884
885 <dl>
886 <dt><kbd>ESTNODERES *est_node_search(ESTNODE *<var>node</var>, ESTCOND *<var>cond</var>, int <var>depth</var>);</kbd></dt>
887 <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>
888 </dl>
889
890 <p>The function `est_node_set_user' is used in order to manage a user account of a node.</p>
891
892 <dl>
893 <dt><kbd>int est_node_set_user(ESTNODE *<var>node</var>, const char *<var>name</var>, int <var>mode</var>);</kbd></dt>
894 <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>
895 </dl>
896
897 <p>The function `est_node_set_link' is used in order to manage a link of a node.</p>
898
899 <dl>
900 <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>
901 <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>
902 </dl>
903
904 <h3>API for Search Results of Nodes</h3>
905
906 <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>
907
908 <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>
909
910 <p>The following is a typical use case of node connection object and result document object.</p>
911
912 <pre>ESTNODERES *nres;
913 CBMAP *hints;
914 ESTRESDOC *rdoc;
915 int i;
916
917 /* create a node result object */
918 nres = est_node_search(node, cond, 1);
919
920 /* get hints */
921 hints = est_noderes_hints(nres);
922
923 /* show the hints here */
924
925 /* scan documents in the result */
926 for(i = 0; i &lt; est_noderes_doc_num(nres); i++){
927
928 /* get a result document object */
929 rdoc = est_noderes_get_doc(nres, i);
930
931 /* show the result document object here */
932
933 }
934
935 /* destroy the node result object */
936 est_noderes_delete(nres);
937 </pre>
938
939 <p>The function `est_noderes_delete' is used in order to delete a node result object.</p>
940
941 <dl>
942 <dt><kbd>void est_noderes_delete(ESTNODERES *<var>nres</var>);</kbd></dt>
943 <dd>`nres' specifies a node result object.</dd>
944 </dl>
945
946 <p>The function `est_noderes_hints' is used in order to get a map object for hints of a node result object.</p>
947
948 <dl>
949 <dt><kbd>CBMAP *est_noderes_hints(ESTNODERES *<var>nres</var>);</kbd></dt>
950 <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>
951 </dl>
952
953 <p>The function `est_noderes_doc_num' is used in order to get the number of documents in a node result object.</p>
954
955 <dl>
956 <dt><kbd>int est_noderes_doc_num(ESTNODERES *<var>nres</var>);</kbd></dt>
957 <dd>`nres' specifies a node result object. The return value is the number of documents in a node result object.</dd>
958 </dl>
959
960 <p>The function `est_noderes_get_doc' is used in order to refer a result document object in a node result object.</p>
961
962 <dl>
963 <dt><kbd>ESTRESDOC *est_noderes_get_doc(ESTNODERES *<var>nres</var>, int <var>index</var>);</kbd></dt>
964 <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>
965 </dl>
966
967 <p>The function `est_resdoc_uri' is used in order to get the URI of a result document object.</p>
968
969 <dl>
970 <dt><kbd>const char *est_resdoc_uri(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
971 <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>
972 </dl>
973
974 <p>The function `est_resdoc_attr_names' is used in order to get a list of attribute names of a result document object.</p>
975
976 <dl>
977 <dt><kbd>CBLIST *est_resdoc_attr_names(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
978 <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>
979 </dl>
980
981 <p>The function `est_resdoc_attr' is used in order to get the value of an attribute of a result document object.</p>
982
983 <dl>
984 <dt><kbd>const char *est_resdoc_attr(ESTRESDOC *<var>rdoc</var>, const char *<var>name</var>);</kbd></dt>
985 <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>
986 </dl>
987
988 <p>The function `est_resdoc_snippet' is used in order to get the snippet of a result document object.</p>
989
990 <dl>
991 <dt><kbd>const char *est_resdoc_snippet(ESTRESDOC *<var>rdoc</var>);</kbd></dt>
992 <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>
993 </dl>
994
995 <h3>Paralleling</h3>
996
997 <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>
998
999 <hr />
1000
1001 <h2 id="estcall">Command of a Client</h2>
1002
1003 <p>`estcall' is provided as a client command to manage the node server. This section describes how to use estcall.</p>
1004
1005 <h3>Synopsis and Description</h3>
1006
1007 <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>
1008
1009 <dl>
1010 <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>
1011 <dd>Register a document of document draft to a node.</dd>
1012 <dd><var>file</var> specifies a target file. If it is omitted, the standard input is read.</dd>
1013 </dl>
1014
1015 <dl>
1016 <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>
1017 <dd>Remove information of a document from a node.</dd>
1018 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
1019 </dl>
1020
1021 <dl>
1022 <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>
1023 <dd>Output document draft of a document in a node.</dd>
1024 <dd><var>expr</var> specifies the ID number or the URI of a document.</dd>
1025 <dd>If <var>attr</var> is specified, only the value of the attribute is output.</dd>
1026 </dl>
1027
1028 <dl>
1029 <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>
1030 <dd>Output the ID number of a document specified by URI.</dd>
1031 <dd><var>uri</var> specifies the URI of a document.</dd>
1032 </dl>
1033
1034 <dl>
1035 <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>
1036 <dd>Outout the name, the label, the number of documents, and the number of unique words of a node.</dd>
1037 </dl>
1038
1039 <dl>
1040 <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>
1041 <dd>Search a node for documents.</dd>
1042 <dd><var>phrase</var> specifies the search phrase.</dd>
1043 <dd>If -vx is specified, XML including including attributes and snippets is output.</dd>
1044 <dd>-attr specifies an attribute search condition. This option can be specified multiple times.</dd>
1045 <dd>-ord specifies the order expression. By default, it is descending by score.</dd>
1046 <dd>-max specifies the maximum number of show documents. Negative means unlimited. By default, it is 10.</dd>
1047 <dd>-dpt specifies depth of meta search. by default it is 0.</dd>
1048 </dl>
1049
1050 <dl>
1051 <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>
1052 <dd>Set permission of a user.</dd>
1053 <dd><var>name</var> specifies the name of a user.</dd>
1054 <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>
1055 </dl>
1056
1057 <dl>
1058 <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>
1059 <dd>Set a link to another node.</dd>
1060 <dd><var>url</var> specifies the URL of a destination node.</dd>
1061 <dd><var>label</var> specifies the label of the link.</dd>
1062 <dd><var>credit</var> specifies the credit of the link. If the value is negative, the link is removed.</dd>
1063 </dl>
1064
1065 <dl>
1066 <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>
1067 <dd>Outout response of an HTTP request.</dd>
1068 <dd><var>url</var> specifies the URL of a target.</dd>
1069 <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>
1070 <dd>If -np is specified, output response headers also.</dd>
1071 <dd>-eh specifies an additional HTTP header. By default, "Host", "Connection", "User-Agent", and "Content-Length" is added.</dd>
1072 </dl>
1073
1074 <p>All sub commands return 0 if the operation is success, else return 1.</p>
1075
1076 <h3>Examples</h3>
1077
1078 <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>
1079
1080 <pre>estcall raw -auth admin admin \
1081 'http://localhost:1978/master?action=shutdown'
1082 </pre>
1083
1084 <p>In order to add a user, perform the following command.</p>
1085
1086 <pre>estcall raw -auth admin admin \
1087 'http://localhost:1978/master?action=useradd&amp;name=mikio&amp;passwd=iloveyou'
1088 </pre>
1089
1090 <p>In order to use POST method, perform the following command.</p>
1091
1092 <pre>echo -n 'action=useradd&amp;name=mikio&amp;passwd=iloveyou' |
1093 estcall raw -auth admin admin \
1094 -eh 'Content-Type: application/x-www-form-urlencoded' \
1095 'http://localhost:1978/master' -
1096 </pre>
1097
1098 <hr />
1099
1100 </body>
1101
1102 </html>
1103
1104 <!-- END OF FILE -->

  ViewVC Help
Powered by ViewVC 1.1.26