blog.Ring.idv.tw

Lucene

Katta - distribute lucene indexes in a grid

在資訊檢索的領域中~ 「Lucene」算是表現最為突出的一個全文檢索函式庫,想當然~ 本站的搜尋功能就是用「Lucene」來建構的~

不過~ 雖然Lucene相當好用~ 但... 如果「index」太大呢?或者「index」比一整顆硬碟還大呢?是否需要負載平衡來分散處理?...

Katta」就是要改善這樣的問題~ 所以它系建構在「Hadoop」和「Zookeeper」之上~ 採用「Apache Version 2 License」,並在今年的9月17日釋出了「katta-0.1.0」版~

上圖就是我在Cygwin的環境下照著「katta : Getting started」所跑出來的測試結果~ 總之又是一個值得關注的Project~ 期待它能隨著Zookeeper的腳步加入Apache的計畫之下~

katta是什麼呢?

環尾狐猴

相關資源

How Katta works.

Install and configure Katta

find23.net: katta-overview(pdf)

find23.net: katta, pig and hadoop in production - experience report slides

2008-09-29 19:11:27 | Comments (2)

快速上手 - Lucene

Lucene是一個開放原始碼的資訊檢索函式庫,最初是由 Doug Cutting 利用Java程式實作完成的,它目前是 Apache Software Foundation 底下的計畫之一,由於相當的受到肯定,所以也洐生出其它的程式版本,如:Perl, C#, C++, Python, Ruby and PHP。

建立Index

一個個搜尋檔案的方式,其實是相當耗時且緩慢的,所以我們必須先為我們想要搜尋的文件建立索引,就如同書籍中提供在最後面的索引頁,可以幫助我們更快速的找到我們想要知道的東西。

Step 1:假設我們想要索引的文件放置在「D:\index」

Step 2:切換工作目錄到你的lucene目錄夾,並輸入下列指令

D:\lucene-2.1.0>java -cp .;lucene-core-2.1.0.jar;lucene-demos-2.1.0.jar org.apache.lucene.demo.IndexFiles d:\index

若出現以下類似的訊息即代表已成功索引,並會在此目錄下建立一個「index」的資料夾,底下包含了三個檔案,簡單來說就是已被索引的資訊。

Indexing to directory 'index'...
adding d:\index\Wang.txt
adding d:\index\Apollo.txt
adding d:\index\JavaFX.txt
adding d:\index\Silverlight.txt
Optimizing...
500 total milliseconds

Command搜尋

接著我們要搜尋剛剛被我們索引的那些文件中的內容~請輸入下列指令

D:\lucene-2.1.0>java -cp .;lucene-core-2.1.0.jar;lucene-demos-2.1.0.jar org.apache.lucene.demo.SearchFiles

接著會出現「Query:」的提示字元,你就可以輸入你想要搜尋的資訊囉~

例如:

Searching for: ajax
2 total matching documents
1. d:\index\Silverlight.htm
2. d:\index\Apollo.htm

Web搜尋

位於lucene目錄底下有一個「luceneweb.war」檔,請將它拷貝至你的Application Server的部署目錄下,例如:Tomcat or JBoss 等…

以Tomcat為例,啟動你的Tomcat之後,它會將此檔解壓縮成luceneweb的目錄夾,接著請修改此目錄夾底下的「configuration.jsp」如下所示:

//String indexLocation = "/opt/lucene/index";
String indexLocation = "D:\\lucene-2.1.0\\index";

也就是設定剛剛索引文件的目錄位置即可,最後開啟http://localhost:8080/luceneweb/就開始享受Lucene吧~

2007-05-18 17:56:03 | Add Comment

Copyright (C) Ching-Shen Chen. All rights reserved.

::: 搜尋 :::

::: 分類 :::

::: Ads :::

::: 最新文章 :::

::: 最新回應 :::

::: 訂閱 :::

Atom feed
Atom Comment