1
2

FESS で Redmine Wiki をクロールしたい

Last updated at Posted at 2023-01-17
  • 社内 Redmine の Wiki の記事が増えてきたので効率的に検索したい
  • 全文検索サーバー FESS を導入(14.5.0)
  • Wikiはプロジェクト毎にあって、階層化されている
これを一気にクロールする方法

クローラーの設定

  • ウェブではなく、データストアからクロールする
  • プラグイン fess-ds-db & fess-crawler-db-mysql を入れる

データストアのクロール設定

  • ハンドラー名「DatabaseDataStore」を指定

パラメーターで指定するSQL文

.sql
sql=select
       wp.id as id ,wp.wiki_id as wiki_id ,wp.title as title ,
       w.project_id as project_id ,p.identifier as identifier,
       wc.text as text, 
       DATE_FORMAT(wc.updated_on,'%Y-%m-%dT%H:%i:%s.00Z') AS 
       last_modified_dt 
     from 
       wikis w, wiki_pages wp, wiki_contents wc, projects p 
     where 
       wp.wiki_id=w.id and wp.id=wc.page_id and w.project_id=p.id

url に埋め込むプロジェクトID:identifier
url に埋め込むタイトル:title
検索結果を期間で絞り込みたいので更新日を取得:update_on → last_modified_dt

パラメーターに記載するSQLは1行で記載しないとエラーになります。

.sql
sql=select wp.id as id ,wp.wiki_id as wiki_id ,wp.title as title ,w.project_id as project_id ,p.identifier as identifier, wc.text as text, DATE_FORMAT(wc.updated_on,'%Y-%m-%dT%H:%i:%s.00Z') AS last_modified_dt from wikis w, wiki_pages wp, wiki_contents wc, projects p where wp.wiki_id=w.id and wp.id=wc.page_id and w.project_id=p.id
  • パラメータ
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://172.xx.xx.xx:3306/bitnami_redmine?useUnicode=true&characterEncoding=UTF-8
username=adminUser
password=dbAdminPass
sql=select wp.id as id ,wp.wiki_id as wiki_id ,wp.title as title ,w.project_id as project_id ,p.identifier as identifier, wc.text as text, DATE_FORMAT(wc.updated_on,'%Y-%m-%dT%H:%i:%s.00Z') AS last_modified_dt from wikis w, wiki_pages wp, wiki_contents wc, projects p where wp.wiki_id=w.id and wp.id=wc.page_id and w.project_id=p.id
  • スクリプト

url="https://xxx.xx.xx.xx/redmine/projects/" + identifier + "/wiki/" + title
host="https://xxx.xx.xx.xx/"
site="https://xxx.xx.xx.xx/redmine/projects/" + identifier + "/wiki/"
title="【Redmine - wiki】" + title
content=text
cache=text
digest=title
anchor=
content_length=content.length()
last_modified=last_modified_dt
timestamp=last_modified_dt

  • スクリプトのパラメータ timestamp に更新日を入れると検索結果から期間での絞込みが可能になる

Redmine Wiki DB構造

DB構造_Redmine.jpg

1
2
0

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
  3. You can use dark theme
What you can do with signing up
1
2