Register now and start sharing your code 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

Shell Script (Bash) posted about 1 year ago by christian

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:

   1  $ cd /usr/local/src
   2  $ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
   3  $ tar zxvf libiconv-1.11.tar.gz
   4  $ cd libiconv-1.11
   5  $ ./configure
   6  $ make
   7  $ sudo make install

zlib:

   1  $ cd /usr/local/src
   2  $ wget http://www.zlib.net/zlib-1.2.3.tar.gz
   3  $ tar zxvf zlib-1.2.3.tar.gz
   4  $ ./configure
   5  $ make
   6  $ sudo make install

QDBM :

   1  $ cd /usr/local/src
   2  $ wget http://qdbm.sourceforge.net/qdbm-1.8.74.tar.gz
   3  $ tar zxvf qdbm-1.8.74.tar.gz
   4  $ cd qdbm-1.8.74
   5  $ ./configure --enable-zlib
   6  $ make mac
   7  $ make check-mac
   8  $ sudo make install-mac

Hyper Estraier

   1  $ cd /usr/local/src
   2  $ wget http://hyperestraier.sourceforge.net/hyperestraier-1.4.9.tar.gz
   3  $ tar zxvf hyperestraier-1.4.9.tar.gz
   4  $ cd hyperestraier-1.4.9
   5  $ ./configure
   6  $ make mac
   7  $ make check-mac
   8  $ sudo make install-mac

Finally we’ll install the pure ruby bindings:

   1  $ cd rubypure
   2  $ ./configure
   3  $ make
   4  $ 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:

   1  estmaster init casket
   2  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:

   1  require "estraierpure"
   2  include EstraierPure
   3  
   4  node = Node::new
   5  node.set_url("http://localhost:1978/node/dictionary")
   6  node.set_auth("admin", "admin")
   7  
   8  doc = Document::new
   9  # @uri : the location of a document which any document should have.
  10  doc.add_attr("@uri", "This is the URL, required?")
  11  # @title : the title used as a headline in the search result.
  12  doc.add_attr("@title", "This is the title, required?")
  13  doc.add_text("Text goes here")
  14  
  15  result = node.put_doc(doc)
  16  unless result
  17    printf("error: %s\n", node.status)
  18  end

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

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

The query language is documented here.

If you’re indexing ActiveRecord objects use acts_as_searchable:

   1  gem install acts_as_searchable

Tagged hyper estraier, search, ruby, install