プロフィール

Author:dogyear2nd

カレンダー
04 | 2012/05 | 06
- - 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 - -
最近の記事
最近のコメント
最近のトラックバック
月別アーカイブ
カテゴリー
スポンサーサイト
上記の広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書く事で広告が消せます。

スポンサー広告 | 【--------(--) --:--:--】
Trackback(-) | Comments(-)
lucene-gosen 辞書単語追加 Memo
lucene-gosenの辞書へ単語を追加する

Export source code

svn export http://lucene-gosen.googlecode.com/svn/tags/rel-1.1.0 lucene-gosen-1.1.0



Edit build.xml

sed -i.bak 's/1.1-dev/1.1.0/' lucene-gosen-1.1.0/build.xml
rm lucene-gosen-1.1.0/build.xml.bak



Build lucene-gosen

cd lucene-gosen-1.1.0
ant -Ddictype=naist-chasen



この時点のdist/lucene-gosen-1.1.0-naist-chasen.jarを使って「ホリエモン」をトークナイズする。
ユーザー辞書なしの場合
「ホリエモン」→「ホ」「リエ」「モン」に形態素解析されてしまう。
「ホリエモン」は「ホリエモン」としたい場合、lucene-gosenの辞書へ単語を登録。


Edit dictionary

cd dictionary
vi naist-chasen/userdictionary.csv


下記1行を記述

"ホリエモン",3999,名詞,一般,*,*,*,*,"ホリエモン","ホリエモン","ホリエモン"




Clean dictionary

ant -Ddictype=naist-chasen clean-sen




Compile dictionary

ant -Ddictype=naist-chasen -Dcustom.dics=userdictionary.csv




Build lucene-gosen

cd ../
ant -Ddictype=naist-chasen



buildし直して出来上がったdist/lucene-gosen-1.1.0-naist-chasen.jarを使って改めて「ホリエモン」をトークナイズする。
ユーザー辞書ありの場合
「ホリエモン」は「ホリエモン」という単語にすることができる。

Lucene/Solr | 【2011-06-28(Tue) 22:32:31】
Trackback:(0) | Comments:(0)
Solr 3.2のJettyアクセスログ
Jettyのログが出てなかったので
etc/jetty.xml
を変更。

<!-- =========================================================== -->
<!-- Configure Request Log -->
<!-- Request logs may be configured for the entire server here, -->
<!-- or they can be configured for a specific web app in a -->
<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
<!-- for an example). -->
<!-- =========================================================== -->
<Ref id="RequestLog">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
<Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">false</Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
</Ref>



コメントアウトされていたところを有効にする。

Lucene/Solr | 【2011-06-15(Wed) 23:17:49】
Trackback:(0) | Comments:(0)
lucene-gosen覚え書き
lucene-gosenのソースチェックアウト

svn checkout http://lucene-gosen.googlecode.com/svn/tags/rel-1.1.0 lucene-gosen-1.1.0



trunkからもってくると配布しているバイナリのバージョンと一致しないかもしれないので。。。

http://code.google.com/p/lucene-gosen/source/browse/

Lucene/Solr | 【2011-06-13(Mon) 23:51:21】
Trackback:(0) | Comments:(0)
Solr 4.0の Admin Interfaceがカッコ良くなっている
Solrのtrunkから改めてbuildし直したらAdmin Interfaceのデザインがカッコ良くなっている!
でもいろいろ動かないのが残念。
Solr 4.0 Admin Interface


Lucene/Solr | 【2011-05-29(Sun) 16:54:40】
Trackback:(0) | Comments:(0)
SolrCloudで作るお手軽分散検索プラットフォーム
Solr 3.1がリリースされたがまだZooKeeperは組み込まれていない。
そこで開発中の最新のSolrのtrunkからソースをチェックアウトして
ZooKeeperと連動して動く分散検索環境をお手軽に作る手順をメモ。



手順1. 上記URLを参考にSVNからソースを取得

svn checkout https://svn.apache.org/repos/asf/lucene/dev/trunk dev





手順2. 続いてsolrディレクトリへ移動してexampleをbuildする

cd dev/solr
ant example
cd




手順3. 構築先のディレクトリを作成

mkdir cloud




手順4. SVNからexampleを構築先のディレクトリへexportする

svn export dev/solr/example cloud/master1




手順5. 手順3でbuildされたsolr.warをコピーしてくる

cp -p dev/solr/example/webapps/solr.war cloud/master1/webapps/.




手順6. せっかくなのでlucene-gosenももってくる

mkdir cloud/master1/solr/lib
curl -o cloud/master1/solr/lib/lucene-gosen-1.0.1-ipadic.jar http://lucene-gosen.googlecode.com/files/lucene-gosen-1.0.1-ipadic.jar




手順7. DistributedUpdateProcessorFactory.javaをbuildし、jarを作る

mkdir -p lucid/com/lucid/update
curl -o lucid/com/lucid/update/DistributedUpdateProcessorFactory.java https://issues.apache.org/jira/secure/attachment/12470726/DistributedUpdateProcessorFactory.java
cd lucid
javac -cp ../dev/solr/dist/apache-solr-core-4.0-SNAPSHOT.jar:../dev/solr/dist/apache-solr-solrj-4.0-SNAPSHOT.jar:../dev/solr/lib/commons-httpclient-3.1.jar:../dev/lucene/build/lucene-core-4.0-SNAPSHOT.jar:../dev/solr/lib/slf4j-api-1.6.1.jar com/lucid/update/DistributedUpdateProcessorFactory.java
jar -cvf lucid-contrib.jar com/lucid/update/*.class
cd



手順8. 手順7で作成したjarファイルをコピー

cp -p lucid/lucid-contrib.jar cloud/master1/solr/lib/.




手順9. lucene-gosenの設定を追加

vi cloud/master1/solr/conf/schema.xml


下記XMLを追加

<fieldType name="text_ja" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="false">
<analyzer>
<tokenizer class="solr.JapaneseTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>




手順10. DistributedUpdateProcessorの設定を追加

vi cloud/master1/solr/conf/solrconfig.xml


下記XMLを追加

<updateRequestProcessorChain name="distrib">
<processor class="com.lucid.update.DistributedUpdateProcessorFactory">
<!-- <str name="self">localhost:8983/solr/collection1</str> -->
<arr name="shards">
<str>localhost:9000/solr/collection1</str>
<str>localhost:9010/solr/collection1</str>
<str>localhost:9020/solr/collection1</str>
</arr>
</processor>
<processor class="solr.LogUpdateProcessorFactory">
<int name="maxNumToLog">10</int>
</processor>
<processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>



手順11. レプリケーションの設定を追加

vi cloud/master1/solr/conf/solrconfig.xml


下記XMLを追加

<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="enable">${enable.master:false}</str>
<str name="replicateAfter">startup</str>
<str name="replicateAfter">commit</str>
<str name="replicateAfter">optimize</str>
</lst>
<lst name="slave">
<str name="enable">${enable.slave:false}</str>
<str name="masterUrl">${master.url:http://localhost:8983/solr}/${solr.core.name:collection1}/replication</str>
<str name="pollInterval">${slave.polling:00:00:60}</str>
</lst>
</requestHandler>




手順12. 分散検索、分散インデックスのためのShardを準備する

sed -ibak 's/ defaultCoreName="collection1"//' cloud/master1/solr/solr.xml
# レプリケーションの際にうまくsolr.core.nameが取得できないのでdefaultCoreNameの記述を削除
cp -rp cloud/master1 cloud/master2
cp -rp cloud/master1 cloud/master3
sed -ibak 's/shard1/shard2/g' cloud/master2/solr/solr.xml
sed -ibak 's/shard1/shard3/g' cloud/master3/solr/solr.xml
cp -rp cloud/master1 cloud/slave1
cp -rp cloud/master2 cloud/slave2
cp -rp cloud/master3 cloud/slave3




手順13. Solrの起動

master1

cd cloud/master1
java -Djetty.port=9000 -DhostPort=9000 -Denable.master=true -Dbootstrap_confdir=./solr/conf -Dcollection.configName=myconf -DzkRun -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar



master2

cd cloud/master2
java -Djetty.port=9010 -DhostPort=9010 -Denable.master=true -DzkRun -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar



master3

cd cloud/master3
java -Djetty.port=9020 -DhostPort=9020 -Denable.master=true -DzkRun -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar



slave1

cd cloud/slave1
java -Djetty.port=9030 -DhostPort=9030 -Denable.slave=true -Dmaster.url=http://localhost:9000/solr -Dslave.polling=00:00:30 -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar



slave2

cd cloud/slave2
java -Djetty.port=9040 -DhostPort=9040 -Denable.slave=true -Dmaster.url=http://localhost:9010/solr -Dslave.polling=00:00:30 -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar



slave3

cd cloud/slave3
java -Djetty.port=9050 -DhostPort=9050 -Denable.slave=true -Dmaster.url=http://localhost:9020/solr -Dslave.polling=00:00:30 -DzkHost=localhost:10000,localhost:10010,localhost:10020 -jar start.jar





手順14. 分散インデックスと分散検索の実施

feed

curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/hd.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/ipod_other.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/ipod_video.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/ipod_video.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/mem.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/monitor.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/monitor2.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/mp500.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/sd500.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary @dev/solr/example/exampledocs/vidcard.xml
curl http://localhost:9000/solr/collection1/update?update.chain=distrib -H "Content-Type: text/xml" --data-binary '<commit/>'




search

http://localhost:9000/solr/collection1/select/?q=ipod&distrib=true


SolrCloud ScreenShot
出来上がり。


参考URL
SolrCloud - Solr Wiki
http://wiki.apache.org/solr/SolrCloud

SolrReplication - Solr Wiki
http://wiki.apache.org/solr/SolrReplication

[#SOLR-2355] simple distrib update processor - ASF JIRA
https://issues.apache.org/jira/browse/SOLR-2355

lucene-gosen - Japanese analysis for Apache Lucene/Solr 3.1 and 4.0 - Google Project Hosting
http://code.google.com/p/lucene-gosen/


Lucene/Solr | 【2011-05-19(Thu) 00:39:44】
Trackback:(0) | Comments:(0)
次のページ

follow me at http://twitter.com