/[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 8 - (show annotations)
Wed Aug 3 13:29:05 2005 UTC (18 years, 9 months ago) by dpavlin
File MIME type: text/html
File size: 56091 byte(s)
final touches for next few weeks...

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

  ViewVC Help
Powered by ViewVC 1.1.26