概要
前回はIndexの構成、関連file種別及びその内容を見てみました。
今日は、Solrの様々なコマンド実行時、Index(のsegment)が実際どうように変化するかを見てみましょう。
Solrコマンド
今日検証するのはadd,update,atomic updates,delete,rollback,softcommit,optimizeなどのコマンドです。
検証前準備
- 検証のため、solrconfig.xmlから自動コミット設定(autoCommit,autoSoftCommit)をコメントアウト(無効に)しています。
- Solr各種コマンドのリクエスト発行には、cURL(Client for URLs)のコマンドラインツールを使用します。
- Mac OS X環境で検証していますので、他のOSでは適宜コマンドを変えて頂きたく。
検証開始
add command
まず、1document登録します。
- 登録用XMLファイル test-add1.xml
$ cat test-add1.xml
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
<field name="manu">Bank of America</field>
<field name="manu_id_s">boa</field>
<field name="cat">currency</field>
<field name="cat">USD</field>
<field name="features">Coins and notes</field>
<field name="price_c">1,USD</field>
<field name="inStock">true</field>
</doc>
</add>
- dataディレクトリを削除し、solr起動
$ rm -Rf $SOLR_HOME/collection1/data
$ java -jar start.jar
- add
$ curl http://localhost:8983/solr/collection1/update -H "Content-Type: text/xml" --data-binary @test-add1.xml
- dataディレクトリを確認(inode numberを表示)
segment情報のみで関連ファイルはできていません(commitがまだなので)。
$ ls -lRi $SOLR_HOME/collection1/data
total 0
24661705 drwxr-xr-x 5 mingchunzhao staff 170 12 25 04:26 index
24661709 drwxr-xr-x 3 mingchunzhao staff 102 12 25 04:31 tlog
/Users/mingchunzhao/study/solr-4.10.2/example/solr/collection1/data/index:
total 16
24661708 -rw-r--r-- 1 mingchunzhao staff 36 12 25 04:26 segments.gen
24661707 -rw-r--r-- 1 mingchunzhao staff 53 12 25 04:26 segments_1
24661706 -rw-r--r-- 1 mingchunzhao staff 0 12 25 04:26 write.lock
/Users/mingchunzhao/study/solr-4.10.2/example/solr/collection1/data/tlog:
total 8
24664242 -rw-r--r-- 1 mingchunzhao staff 205 12 25 04:31 tlog.0000000000000000000
- commit
$ curl http://localhost:8983/solr/collection1/update?commit=true
- dataディレクトリを確認
commitしたらIndexにデータが反映され、各種ファイルができあがりました(中身は前回みましたので割愛)。
$ ls -lRi $SOLR_HOME/collection1/data
total 0
24661705 drwxr-xr-x 15 mingchunzhao staff 510 12 25 04:40 index
24661709 drwxr-xr-x 3 mingchunzhao staff 102 12 25 04:31 tlog
/Users/mingchunzhao/study/solr-4.10.2/example/solr/collection1/data/index:
total 96
24665192 -rw-r--r-- 1 mingchunzhao staff 149 12 25 04:40 _0.fdt
24665188 -rw-r--r-- 1 mingchunzhao staff 63 12 25 04:40 _0.fdx
24665184 -rw-r--r-- 1 mingchunzhao staff 1211 12 25 04:40 _0.fnm
24665187 -rw-r--r-- 1 mingchunzhao staff 42 12 25 04:40 _0.nvd
24665190 -rw-r--r-- 1 mingchunzhao staff 81 12 25 04:40 _0.nvm
24665189 -rw-r--r-- 1 mingchunzhao staff 334 12 25 04:40 _0.si
24665185 -rw-r--r-- 1 mingchunzhao staff 83 12 25 04:40 _0_Lucene41_0.doc
24665186 -rw-r--r-- 1 mingchunzhao staff 82 12 25 04:40 _0_Lucene41_0.pos
24665191 -rw-r--r-- 1 mingchunzhao staff 771 12 25 04:40 _0_Lucene41_0.tim
24665193 -rw-r--r-- 1 mingchunzhao staff 375 12 25 04:40 _0_Lucene41_0.tip
24665195 -rw-r--r-- 1 mingchunzhao staff 36 12 25 04:40 segments