LoginSignup
1

More than 1 year has passed since last update.

CentOS7でFessを使用し、ローカルファイル検索を試す

Last updated at Posted at 2021-01-11

Fessを使用して、ローカルファイルの全文検索を試す。
オープンソース全文検索サーバー Fess

特に理由はないが、JDK以外はzipをダウンロードして設置する。
rpmからインストールする場合はこちら

インストール先のCentOSのバージョン。

CentOS Linux release 7.9.2009 (Core)

ドキュメントがあるので、特に詰まるところはなかった。
試すだけなので、すべてホームディレクトリで実行。

JDKのインストール

sudo yum install java-11-openjdk-devel

動作するか確認

次のファイルを設置し、コンパイルし、問題なく動くかを確認する

HelloWorld.java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        System.out.println(System.getProperty("java.version"));
    }
}
javac HelloWorld.java
java HelloWorld

Elasticsearchの設置

Download Elasticsearch Free | Get Started Now | Elastic | Elastic からダウンロード。
この時点での最新は7.10.1。

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.10.1-linux-x86_64.tar.gz

Fessの設置

githubからfessの最新コードを取得。
Releases · codelibs/fess · GitHub
この時点での最新は13.10.2。

wget https://github.com/codelibs/fess/releases/download/fess-13.10.2/fess-13.10.2.zip
unzip fess-13.10.2.zip

ディレクトリ名を変更しておく。

mv elasticsearch-7.10.1 elasticsearch
mv fess-13.10.2 fess

Elasticsearchの設定

参考: インストール

ElasticsearchにFessのプラグインをインストール。
githubを確認したところ、最新は7.10.0だった。
Tags · codelibs/elasticsearch-analysis-fess · GitHub

./elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-fess:7.10.0
./elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-extension:7.10.0
./elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-configsync:7.10.0
./elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-dataformat:7.10.0
./elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-minhash:7.10.0

./elasticsearch/data/config/を認識させる。
Fessにアクセスするための設定を追記。
パスはフルパスを。

/elasticsearch/config/elasticsearch.yml
configsync.config_path: /path/to/elasticsearch/data/config/

FessでElasticsearchクラスタへ接続するために起動オプションを指定するとのこと。

/fess/bin/fess.in.sh
ES_HTTP_URL=http://localhost:9200
FESS_DICTIONARY_PATH=/path/to/elasticsearch/data/config/

確認

起動させて、ブラウザでアクセスできるか確認する。

./elasticsearch/bin/elasticsearch
./fess/bin/fess

http://[サーバのIP]:8080 でアクセスできるか確認
http://[サーバのIP]:8080/admin が管理ログイン画面。
ID: admin
PASS: admin

アクセスできない場合はfirewallまわりを確認する。

ローカルファイルのクロール

設定

参考: ファイルクロール

今回は/var/fess下にファイルを設置し、このディレクトリ下のファイルを全文検索できるようにする。
管理画面にログインし、左メニュークローラー -> ファイルシステムで次のように登録。

名前: 適当
パス file:/var/fess/
クロール対象とするパス file:/var/fess/.*

即時実行したいので、システム -> スケジューラで「Default Crawler」をクリックし、「今すぐ開始ボタン」をクリックしてクロール実行。
システム情報 -> クロール情報でクロール状態や結果が確認できるので、終わったらデータが取れているかを確認する。

システム情報 -> 検索から検索できるかを確認する。

検索インデックスを消したい場合

参考: Fess のインデックスからドキュメントを削除 – with a Christian Wife

システム情報->検索で「*:*」を入力して検索し、画面下部の削除ボタンで削除。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
1