= MoinMoinにXapian導入 = == セットアップ == 検索に時間がかかるようになったのでXapianの導入を再検討した。 調べたところタイミングの良いことにXapian-1.2.8からN-gramをサポートして日本語を処理できるようになっていた。 まず http://d.hatena.ne.jp/z3100/20110505/1304559789 を参考にXapianを通常通りセットアップした。導入したバージョンは1.2.12である。portsに入っているxapianは古かったので使用しなかった。 {{{ $ cd xapian-core-1.2.12 $ ./configure --prefix=/opt/xapian && make $ sudo make install $ cd ../ $ cd xapian-omega-1.2.12 $ ./configure --prefix=/opt/xapian XAPIAN_CONFIG=/opt/xapian/bin/xapian-config && make $ sudo make install $ cd ../ $ cd xapian-bindings-1.2.12 $ ./configure --prefix=/opt/xapian XAPIAN_CONFIG=/opt/xapian/bin/xapian-config --with-python && make $ sudo make install }}} 追記(2013-03-23): xapian-bindingsのインストール時にはPythonのライブラリのインストール先に/usr/localを指定すべき。{{{ $ PYTHON_LIB=/usr/local/lib/python2.6/dist-packages/ ./configure --prefix=/opt/xapian XAPIAN_CONFIG=/opt/xapian/bin/xapian-config --with-python && make }}} wikiの設定でXapianを有効にした。 {{{ xapian_search = True xapian_index_history = False xapian_index_dir = None xapian_stemming = False }}} さらにN-gramを使用するように設定した。wikiの設定ファイルにこれも書いておく。 {{{ os.environ["XAPIAN_CJK_NGRAM"] = "1" }}} 最後にXapianのデータベースを作成した。この操作はWebサーバの権限で行う必要がある。あるいは自分のユーザで実行した後でchownする。 {{{ $ moin --config-dir=./ --wiki-url=http://www.mma.club.uec.ac.jp/~ytoku/testwiki/ index build --mode=rebuild }}} なお、記事が編集された時のデータベースの更新は自動的に行われることを確認した。 動作しているかは[[SystemInfo]]のページやログで確認できる。 データベースを使用していない時はログに {{{ Slow moin search is used because the Xapian index does not exist. You should create it using the moin index build command. }}} と出力される。データベースを作成したにもかかわらずこれが出るケースとして、Webサーバがデータベースのディレクトリへのアクセス権を持っていない可能性がある。 == バグがいくつかあった == * 記号の直後にある文字が検索対象にならないバグがあるのを見つけた。直さなければ。 * !PageListマクロでページの一覧を出力すると添付ファイルまで表示される。挙動が違う。