Overview | Package | Class | Tree | Index
PREV NEXT | FRAMES NO FRAMES

Java Binding of Hyper Estraier.

See:
Description

Packages
estraier |

# Java Binding of Hyper Estraier.

Hyper Estraier is a full-text search system for communities.

## Introduction

This is a package implementing the core API of Hyper Estraier, including native codes based on JNI. As it works on Linux, Mac OS X, Windows, and so on, native libraries for each environment are required to run programs. This package requires JRE 1.4.2 or later versions.

## Setting

Install the latest version of Hyper Estraier.

Enter the sub directory `javanative' in the extracted package then perform installation.

    cd javanative
    ./configure
    make
    su
    make install

`estraiernative.jar' should be included in the class path. By default, the JAR file is installed in `/usr/local/lib'.

`estraier.*' should be imported in each source file of application programs.

Some native libraries should be found in the library search path.

- On Linux and other UNIX systems: set the environment variable LD_LIBRARY_PATH to find libraries; "libestraier.so" and "libjestraier.so".
- On Mac OS X: set the environment variable DYLD_LIBRARY_PATH to find libraries; "libestraier.dylib" and "libjestraier.dylib".
- On Windows: set the environment variable PATH to find libraries; "estraier.dll" and "jestraier.dll".

## Example of Gatherer

The following is the simplest implementation of a gatherer.

    import estraier.*;

    public class Example001 {
      public static void main(String[] args){

        // create the database object
        Database db = new Database();

        // open the database
        if(!db.open("casket", Database.DBWRITER | Database.DBCREAT)){
          System.err.println("error: " + db.err_msg(db.error()));
          return;
        }

        // create a document object
        Document doc = new Document();

        // add attributes to the document object
        doc.add_attr("@uri", "http://estraier.gov/example.txt");
        doc.add_attr("@title", "Over the Rainbow");

        // add the body text to the document object
        doc.add_text("Somewhere over the rainbow.  Way up high.");
        doc.add_text("There's a land that I heard of once in a lullaby.");

        // register the document object to the database
        if(!db.put_doc(doc, Database.PDCLEAN))
          System.err.println("error: " + db.err_msg(db.error()));

        // close the database
        if(!db.close())
          System.err.println("error: " + db.err_msg(db.error()));

      }
    }

## Example of Searcher

The following is the simplest implementation of a searcher.

    import estraier.*;
    import java.util.*;

    public class Example002 {
      public static void main(String[] args){

        // create the database object
        Database db = new Database();

        // open the database
        if(!db.open("casket", Database.DBREADER)){
          System.err.println("error: " + db.err_msg(db.error()));
          return;
        }

        // create a search condition object
        Condition cond = new Condition();

        // set the search phrase to the search condition object
        cond.set_phrase("rainbow AND lullaby");

        // get the result of search
        Result result = db.search(cond);

        // for each document in the result
        for(int i = 0; i < result.doc_num(); i++){
          // retrieve the document object
          Document doc = db.get_doc(result.get_doc_id(i), 0);
          if(doc == null) continue;
          // display attributes
          String uri = doc.attr("@uri");
          if(uri != null) System.out.println("URI: " + uri);
          String title = doc.attr("@title");
          if(title != null) System.out.println("Title: " + title);
          // display the body text
          Iterator it = doc.texts().iterator();
          while(it.hasNext()){
            System.out.println((String)it.next());
          }
        }

        // close the database
        if(!db.close())
          System.err.println("error: " + db.err_msg(db.error()));

      }
    }

## License

Copyright (C) 2004-2006 Mikio Hirabayashi

The Java binding of Hyper Estraier is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version. The Java binding of Hyper Estraier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the Java binding of Hyper Estraier; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

Overview | Package | Class | Tree | Index
PREV NEXT | FRAMES NO FRAMES