source: project/wiki/estraier @ 7968

Last change on this file since 7968 was 7968, checked in by Mario Domenech Goulart, 12 years ago

Changes applied for mario (201.86.206.48) through svnwiki:

Removing spam.

File size: 2.4 KB
Line 
1[[tags:eggs search]]
2
3[[toc:]]
4
5== Introduction
6
7The Estraier Chicken [[eggs|egg]] is a thin wrapper around the [[http://hyperestraier.sourceforge.net/|Hyper Estraier]]
8[[http://hyperestraier.sourceforge.net/pguide-en.html|API]].
9
10== Examples
11
12=== Indexing a document
13
14The following code receives a path to a Estraier DB and a file
15and adds it to the DB:
16
17<enscript highlight=scheme>(use estraier)
18(define (estraier-update-document path-db path-text)
19  (let ((doc (est-doc-new)))
20
21    ; Here you could use an HTTP URL if your file is visible somewhere:
22    (est-doc-add-attr doc "@uri" path-text)
23    ; You will want to set the title to something more meaningful:
24    (est-doc-add-attr doc "@title" path-text)
25
26    (with-input-from-file path-text
27      (lambda ()
28        (let loop ((line (read-line)))
29          (unless (eof-object? line)
30            ; If your file is not in Unicode, use the iconv egg to convert
31            ; the charset of the lines to Unicode.
32            (est-doc-add-text doc line)
33            (loop (read-line))))))
34
35    (let ((db (est-db-open path-db (bitwise-ior *estdbwriter* *estdbcreat*))))
36      (est-db-put-doc db doc *estpdclean*)
37      (est-db-close db))))
38</enscript>
39
40=== Searching for documents
41
42<enscript highlight=scheme>(use estraier)
43
44(define (estraier-search path-data query)
45  (let ((condition (est-cond-new)))
46    (est-cond-set-phrase condition query)
47    (let* ((db (est-db-open (svnwiki-make-pathname path-data "estraier-db") 0))
48           (hints (cbmapopenex 32))
49           (results (vector->list (est-db-search db condition hints)))
50           (words (est-hints-to-words hints)))
51      (map
52        (lambda (id)
53          (let ((doc (est-db-get-doc db id 0)))
54            (list
55              (est-doc-attr doc "@uri")
56              (est-doc-attr doc "@title")
57              (est-doc-make-snippet doc words 480 96 96))))
58        results))))
59</enscript>
60
61== Authors
62
63This egg is made by [[http://azul.freaks-unidos.net/|Alejandro Forero Cuervo]] <azul@freaks-unidos.net>.
64
65== License
66
67The {{estraier}} egg is available under the GNU General Public License.
68
69== Requirements
70
71In order to build this egg you'll need to have Hyper Estraier and libQDBM.
72Note that you'll need the development packages for both.
73
74=== Debian
75
76In Debian, it suffices to install packages
77{{libestraier-dev}} and {{libqdbm-dev}}.
78The dependencies will take care of the rest.
79
80As of this writing, Hyper Estraier is not available in
81Debian stable.  You'll have to use testing.
Note: See TracBrowser for help on using the repository browser.