/[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 7 - (show annotations)
Sat Jul 30 21:29:42 2005 UTC (18 years, 9 months ago) by dpavlin
File MIME type: text/html
File size: 56100 byte(s)
finished tutorial

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

  ViewVC Help
Powered by ViewVC 1.1.26