You are looking at historical revision 7968 of this page. It may differ significantly from its current revision.
Indexing a document
The following code receives a path to a Estraier DB and a file and adds it to the DB:
(use estraier) (define (estraier-update-document path-db path-text) (let ((doc (est-doc-new))) ; Here you could use an HTTP URL if your file is visible somewhere: (est-doc-add-attr doc "@uri" path-text) ; You will want to set the title to something more meaningful: (est-doc-add-attr doc "@title" path-text) (with-input-from-file path-text (lambda () (let loop ((line (read-line))) (unless (eof-object? line) ; If your file is not in Unicode, use the iconv egg to convert ; the charset of the lines to Unicode. (est-doc-add-text doc line) (loop (read-line)))))) (let ((db (est-db-open path-db (bitwise-ior *estdbwriter* *estdbcreat*)))) (est-db-put-doc db doc *estpdclean*) (est-db-close db))))
Searching for documents
(use estraier) (define (estraier-search path-data query) (let ((condition (est-cond-new))) (est-cond-set-phrase condition query) (let* ((db (est-db-open (svnwiki-make-pathname path-data "estraier-db") 0)) (hints (cbmapopenex 32)) (results (vector->list (est-db-search db condition hints))) (words (est-hints-to-words hints))) (map (lambda (id) (let ((doc (est-db-get-doc db id 0))) (list (est-doc-attr doc "@uri") (est-doc-attr doc "@title") (est-doc-make-snippet doc words 480 96 96)))) results))))
This egg is made by Alejandro Forero Cuervo <firstname.lastname@example.org>.
The estraier egg is available under the GNU General Public License.
In order to build this egg you'll need to have Hyper Estraier and libQDBM. Note that you'll need the development packages for both.
In Debian, it suffices to install packages libestraier-dev and libqdbm-dev. The dependencies will take care of the rest.
As of this writing, Hyper Estraier is not available in Debian stable. You'll have to use testing.