hyper estraier snippets

How to install Hyper Estraier and the Ruby bindings on Mac OS X, including a mini example on how to use the P2P capabilities

Tagged hyper estraier, search, ruby, install  Languages bash

This is a slightly modified version of some Japanese fellow's documention on how to install Hyper Estraier on Mac OS X

First we need libiconv:

$ cd /usr/local/src
$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
$ tar zxvf libiconv-1.11.tar.gz
$ cd libiconv-1.11
$ ./configure
$ make
$ sudo make install

zlib:

$ cd /usr/local/src
$ wget http://www.zlib.net/zlib-1.2.3.tar.gz
$ tar zxvf zlib-1.2.3.tar.gz
$ ./configure
$ make
$ sudo make install

QDBM:

$ cd /usr/local/src
$ wget http://qdbm.sourceforge.net/qdbm-1.8.74.tar.gz
$ tar zxvf qdbm-1.8.74.tar.gz
$ cd qdbm-1.8.74
$ ./configure --enable-zlib
$ make mac
$ make check-mac
$ sudo make install-mac

Hyper Estraier

$ cd /usr/local/src
$ wget http://hyperestraier.sourceforge.net/hyperestraier-1.4.9.tar.gz
$ tar zxvf hyperestraier-1.4.9.tar.gz
$ cd hyperestraier-1.4.9
$ ./configure
$ make mac
$ make check-mac
$ sudo make install-mac

Finally we'll install the pure ruby bindings:

$ cd rubypure
$ ./configure
$ make
$ sudo make install

To verify that Hyper Estraier is installed and working, try one of the examples in the examples folder, or follow these instructions:

First create and start a P2P node:

estmaster init casket
estmaster start casket

Open http://localhost:1978/master\_ui in your browser and create a node called dictionary.

Then run this code which adds a record to the index:

require "estraierpure"
include EstraierPure

node = Node::new
node.set_url("http://localhost:1978/node/dictionary")
node.set_auth("admin", "admin")

doc = Document::new
# @uri : the location of a document which any document should have.
doc.add_attr("@uri", "This is the URL, required?")
# @title : the title used as a headline in the search result.
doc.add_attr("@title", "This is the title, required?")
doc.add_text("Text goes here")

result = node.put_doc(doc)
unless result
  printf("error: %s\n", node.status)
end

Next we'll perform a query which returns the object we just added:

require "estraierpure"
include EstraierPure

# create and configure the node connecton object
node = Node::new
node.set_url("http://localhost:1978/node/dictionary")

# create a search condition object
cond = Condition::new

# set the search phrase to the search condition object
cond.set_phrase("Text goes here")

# get the result of search
nres = node.search(cond, 0);
if nres
  # for each document in the result
  for i in 0...nres.doc_num
    # get a result document object
    rdoc = nres.get_doc(i)
    # display attributes
    value = rdoc.attr("@uri")
    printf("URI: %s\n", value) if value
    value = rdoc.attr("@title")
    printf("Title: %s\n", value) if value
    # display the snippet text */
    printf("%s", rdoc.snippet)
  end
else
  STDERR.printf("error: %d\n", node.status)
end

The query language is documented here.

If you're indexing ActiveRecord objects use acts_as_searchable:

gem install acts_as_searchable