1 |
require "estraier" |
2 |
include Estraier |
3 |
|
4 |
# create and configure the node connecton object |
5 |
node = Node.new |
6 |
node.set_url("http://localhost:1978/node/test1") |
7 |
# create a search condition object |
8 |
cond = Condition.new() |
9 |
# set the search phrase to the search condition object |
10 |
cond.set_phrase("rainbow AND lullaby") |
11 |
# get the result of search |
12 |
nres = node.search(cond, 0); |
13 |
if(nres) |
14 |
# for each document in the result |
15 |
for i in 0...nres.doc_num |
16 |
# get a result document object |
17 |
rdoc = nres.get_doc(i) |
18 |
# display attributes |
19 |
value = rdoc.attr("@uri") |
20 |
printf("URI: %s\n", value) if value |
21 |
value = rdoc.attr("@title") |
22 |
printf("Title: %s\n", value) if value |
23 |
# display the snippet text */ |
24 |
printf("%s", rdoc.snippet) |
25 |
end |
26 |
else |
27 |
STDERR.printf("error: %d\n", node.status) |
28 |
end |