lucene:Lucene 全文检索实战

  Lucene 是 Apache Jakarta 个子项目个全文检索搜索引擎库其提供了简单实用 API通过这些 API可以自行编写对文件(TEXT/XML/HTML等)、目录、数据库全文检索

Features:
* Very fast indexing, minimal RAM required
* Index compression to 30% of original text
* Indexes text and HTML, document es available for XML, PDF and RTF
* Search supports phrase and Boolean queries, plus, minus and quote marks, and parentheses
* Allows single and multiple character wildcards anywhere in the search words, fuzzy search, proximity
* Will search for punctuation such as + or ?
* Field searches for title, author, etc., and date-range searching
* Supports most European languages
* Option to store and display full text of indexed documents
* Search results in relevance order
* APIs for file format conversion, languages and user erfaces


  实战任务:

  1) 编写 Java MyIndexer.java使用 JDBC 取出 MySQL 数据表内容(以某论坛数据做测试)然后通过 org.apache.lucene.index.IndexWriter 创建索引

  2) 编写 Java MySearcher.java通过 org.apache.lucene.search.IndexSearcher 等查询索引

  3) 实现支持中文查询及检索关键字高亮显示

  4) 通过 PHP / Java Integration 实现对 MySearch.java

  5) 实现对 PHP 手册(简体中文) 全文检索

  Java 基本编写完成实现了对中文支持步是将其放到 WEB 上运行首先想到是使用 JSP安装了Apache Tomcat/4.1.24默认发布端口是 8080现在面临个问题是:Apache httpd 端口是 80并且我机器对外只能通过 80 端口进行访问如果将 Tomcat 发布端口改成 80 httpd 就没法对外了而其上 PHP 也将无法在 80 端口运行

  对于这个问题我想到两种方案:

  1、使用 PHP 直接 Java需要做工作是使用 --with-java 重新编译 PHP;

  2、使用 mod_jk 做桥接方式将 servlet 引擎结合到 httpd 中需要做工作是编译 jakarta-tomcat-connectors-jk-1.2.5-src生成 mod_jk.so 给 httpd 使用然后按照 Howto 文档 进行 Tomcat、httpd 配置

  对于第个方案尝试:使用 PHP 直接 Java

  环境

  * PHP 4.3.6 prefix=/usr

  * Apache 1.3.27 prefix=/usr/local/apache

  * j2sdk1.4.1_01 prefix=/usr/local/jdk

  配置步骤

  1) 安装 JDK这个就不多说了到 GOOGLE 可以搜索出这方面大量文章

  2) 重新编译 PHP PHP 版本是 4.3.6:

cd php-4.3.6
./configure --with-java=/usr/local/jdk
make
make


  完成的后会在 PHP lib 下(我是在 /usr/lib/php)有个 php_java.jar同时在扩展动态库存放目录下(我是在 /usr/lib/php/20020429)有个 java.so 文件到这步需要注意个问题有些 PHP 版本生成是 libphp_java.so 文件extension 加载只认 libphp_java.so直接加载 java.so 可能会出现如下:

PHP Fatal error: Unable to load Java Library /usr/local/jdk/jre/lib/i386/libjava.so, error: libjvm.so:
cannot open shared object file: No such file or directory in /home/nio/public_html/java.php _disibledevent=e.getMessage%> -->
  <%
  }  //end
}  //end
%>  
</body>
</html>


Tags:  lucene教程 lucene.net luceneinaction lucene

延伸阅读

最新评论

发表评论