概要
今回は、IndexのSegmentを構成するファイルタイプの中でご紹介できなかったものを検証してみます。
Segmentを構成するファイル種別(残り)
Term Vectors
説明
検索結果ヒットしたドキュメントに関する下記の様々な付加情報を返すための機能です。
term vector, term frequency, inverse document frequency, position, offset
検証
設定
schema.xmlでフィールドtv1,tv2にTerm Vector関連属性がtrueに指定されています。
<field name="tv1" type="text_general" indexed="true" stored="true"
termVectors="true" termPositions="true" termOffsets="true" />
<field name="tv2" type="text_general" indexed="true" stored="true"
termVectors="true" termPositions="true" termOffsets="true" />
登録用XML
$ cat test-tv.xml
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
<field name="tv1">card</field>
<field name="tv2">usb</field>
<field name="cat">currency</field>
</doc>
</add>
dataディレクトリを削除し、solr起動
$ rm -Rf $SOLR_HOME/collection1/data
$ java -jar start.jar
ドキュメント登録
$ curl "http://localhost:8983/solr/collection1/update?commit=true" -H "Content-Type: text/xml" --data-binary @test-tv.xml
dataディレクトリを確認
$ ls -lRi $SOLR_HOME/collection1/data
total 0
28181238 drwxr-xr-x 17 mingchunzhao staff 578 1 12 10:24 index
28181242 drwxr-xr-x 3 mingchunzhao staff 102 1 12 10:24 tlog
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/index:
total 112
28181270 -rw-r--r-- 1 mingchunzhao staff 106 1 12 10:24 _0.fdt
28181266 -rw-r--r-- 1 mingchunzhao staff 62 1 12 10:24 _0.fdx
28181260 -rw-r--r-- 1 mingchunzhao staff 681 1 12 10:24 _0.fnm
28181264 -rw-r--r-- 1 mingchunzhao staff 42 1 12 10:24 _0.nvd
28181268 -rw-r--r-- 1 mingchunzhao staff 91 1 12 10:24 _0.nvm
28181267 -rw-r--r-- 1 mingchunzhao staff 348 1 12 10:24 _0.si
28181265 -rw-r--r-- 1 mingchunzhao staff 86 1 12 10:24 _0.tvd
28181261 -rw-r--r-- 1 mingchunzhao staff 62 1 12 10:24 _0.tvx
28181262 -rw-r--r-- 1 mingchunzhao staff 83 1 12 10:24 _0_Lucene41_0.doc
28181263 -rw-r--r-- 1 mingchunzhao staff 57 1 12 10:24 _0_Lucene41_0.pos
28181269 -rw-r--r-- 1 mingchunzhao staff 382 1 12 10:24 _0_Lucene41_0.tim
28181271 -rw-r--r-- 1 mingchunzhao staff 240 1 12 10:24 _0_Lucene41_0.tip
28181273 -rw-r--r-- 1 mingchunzhao staff 36 1 12 10:24 segments.gen
28181272 -rw-r--r-- 1 mingchunzhao staff 131 1 12 10:24 segments_2
28181239 -rw-r--r-- 1 mingchunzhao staff 0 1 12 10:23 write.lock
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/tlog:
total 8
28181259 -rw-r--r-- 1 mingchunzhao staff 148 1 12 10:24 tlog.0000000000000000000
Term Vector Documents(.tvd)ファイルを確認
term vectorが含まれているドキュメントの情報です。(フィールド値card,usbが確認できますね)
$ od -c $SOLR_HOME/collection1/data/index/_0.tvd
0000000 ? 327 l 027 030 L u c e n e 4 1 S t o
0000020 r e d F i e l d s D a t a \0 \0 \0
0000040 001 002 200 \0 001 002 # p @ \0 l 001 300 001 002
0000060 005 200 001 001 \0 \0 \0 \0 \0 \0 \0 \0 001 001 p c
0000100 a r d u s b 300 ( 223 350 \0 \0 \0 \0 \0 \0
0000120 \0 \0 200 Z ~
Term Vector Index(.tvx)ファイルを確認
tvdにおけるoffsetを保持します(by document id)。
0000000 ? 327 l 027 031 L u c e n e 4 1 S t o
0000020 r e d F i e l d s I n d e x \0 \0
0000040 \0 001 002 001 \0 \0 001 \0 $ \0 001 \0 \0 F 300 (
0000060 223 350 \0 \0 \0 \0 \0 \0 \0 \0 f 304 017 205
Term Vector Fields(.tvf)ファイルはLucene 4.2以降で削除されました。
但し、Lucene 4.10.2のJavaDocで、Index File Formatsにtvfファイルの説明がまだ残されていますので(削除漏れ)ご注意を。
正しくは、Class Lucene42TermVectorsFormatをご参照ください。
DocValues
説明
DocValues機能はドキュメントからフィールド値へのマッピング情報を保持することでソート、ファセットなどの処理が高速になります。
検証
設定
schema.xmlでフィールドdvのdocValues属性をtrueに指定します。
<field name="dv" type="string" indexed="true" stored="true" docValues="true"/>
登録用XML
$ cat test-dv.xml
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
<field name="dv">test</field>
<field name="cat">currency</field>
</doc>
</add>
dataディレクトリを削除し、solr起動
$ rm -Rf $SOLR_HOME/collection1/data
$ java -jar start.jar
ドキュメント登録
$ curl "http://localhost:8983/solr/collection1/update?commit=true" -H "Content-Type: text/xml" --data-binary @test-dv.xml
dataディレクトリを確認
$ ls -lRi $SOLR_HOME/collection1/data
total 0
28184495 drwxr-xr-x 17 mingchunzhao staff 578 1 12 11:07 index
28184499 drwxr-xr-x 3 mingchunzhao staff 102 1 12 11:07 tlog
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/index:
total 112
28184519 -rw-r--r-- 1 mingchunzhao staff 101 1 12 11:07 _0.fdt
28184514 -rw-r--r-- 1 mingchunzhao staff 62 1 12 11:07 _0.fdx
28184509 -rw-r--r-- 1 mingchunzhao staff 664 1 12 11:07 _0.fnm
28184513 -rw-r--r-- 1 mingchunzhao staff 42 1 12 11:07 _0.nvd
28184516 -rw-r--r-- 1 mingchunzhao staff 71 1 12 11:07 _0.nvm
28184515 -rw-r--r-- 1 mingchunzhao staff 372 1 12 11:07 _0.si
28184517 -rw-r--r-- 1 mingchunzhao staff 55 1 12 11:07 _0_Lucene410_0.dvd
28184512 -rw-r--r-- 1 mingchunzhao staff 114 1 12 11:07 _0_Lucene410_0.dvm
28184510 -rw-r--r-- 1 mingchunzhao staff 83 1 12 11:07 _0_Lucene41_0.doc
28184511 -rw-r--r-- 1 mingchunzhao staff 55 1 12 11:07 _0_Lucene41_0.pos
28184518 -rw-r--r-- 1 mingchunzhao staff 349 1 12 11:07 _0_Lucene41_0.tim
28184520 -rw-r--r-- 1 mingchunzhao staff 213 1 12 11:07 _0_Lucene41_0.tip
28184522 -rw-r--r-- 1 mingchunzhao staff 36 1 12 11:07 segments.gen
28184521 -rw-r--r-- 1 mingchunzhao staff 131 1 12 11:07 segments_2
28184496 -rw-r--r-- 1 mingchunzhao staff 0 1 12 11:06 write.lock
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/tlog:
total 8
28184508 -rw-r--r-- 1 mingchunzhao staff 138 1 12 11:07 tlog.0000000000000000000
Per-Document Values(.dvd,.dvm)ファイルを確認
付加的なスコアリングファクタやその他per-document情報を保持します。
#docValuesのデータ(dvのフィールド値testが確認できますね)
$ od -c $SOLR_HOME/collection1/data/index/_0_Lucene410_0.dvd
0000000 ? 327 l 027 026 L u c e n e 4 1 0 D o
0000020 c V a l u e s D a t a \0 \0 \0 \0 t
0000040 e s t \0 \0 \0 \0 300 ( 223 350 \0 \0 \0 \0 \0
0000060 \0 \0 \0 ) 217 030 225
#docValuesのメタデータ
$ od -c $SOLR_HOME/collection1/data/index/_0_Lucene410_0.dvm
0000000 ? 327 l 027 027 L u c e n e 4 1 0 V a
0000020 l u e s M e t a d a t a \0 \0 \0 \0
0000040 003 002 003 001 \0 377 377 377 377 377 377 377 377 004 004 001
0000060 \0 \0 \0 \0 \0 \0 \0 037 003 \0 \0 377 377 377 377 377
0000100 377 377 377 \0 \0 \0 \0 \0 \0 \0 # 001 \0 \0 \0 \0
0000120 \0 \0 \0 \0 001 \0 \0 \0 \0 \0 \0 \0 ' 377 377 377
0000140 377 017 300 ( 223 350 \0 \0 \0 \0 \0 \0 \0 \0 341 156
0000160 n s
Compound File
説明
一つの"仮想"ファイルに全てのIndexファイルを含めることでファイルハンドラリソースが貧弱なシステムで有益です。
検証
設定
solrconfig.xmlでuseCompoundFileをtrueに指定します。
<useCompoundFile>true</useCompoundFile>
登録用XML
$ cat test-cf.xml
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
</doc>
</add>
dataディレクトリを削除し、solr起動
$ rm -Rf $SOLR_HOME/collection1/data
$ java -jar start.jar
ドキュメント登録
$ curl "http://localhost:8983/solr/collection1/update?commit=true" -H "Content-Type: text/xml" --data-binary @test-cf.xml
dataディレクトリを確認
$ ls -lRi $SOLR_HOME/collection1/data
total 0
28190389 drwxr-xr-x 8 mingchunzhao staff 272 1 12 11:46 index
28190393 drwxr-xr-x 3 mingchunzhao staff 102 1 12 11:46 tlog
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/index:
total 40
28190403 -rw-r--r-- 1 mingchunzhao staff 284 1 12 11:46 _0.cfe
28190402 -rw-r--r-- 1 mingchunzhao staff 1275 1 12 11:46 _0.cfs
28190404 -rw-r--r-- 1 mingchunzhao staff 241 1 12 11:46 _0.si
28190406 -rw-r--r-- 1 mingchunzhao staff 36 1 12 11:46 segments.gen
28190405 -rw-r--r-- 1 mingchunzhao staff 131 1 12 11:46 segments_2
28190390 -rw-r--r-- 1 mingchunzhao staff 0 1 12 11:46 write.lock
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/tlog:
total 8
28190401 -rw-r--r-- 1 mingchunzhao staff 115 1 12 11:46 tlog.0000000000000000000
Compound File(.cfs, .cfe)ファイルを確認
Segment情報関連ファイル以外のファイルタイプは消えてしまい、Compound Fileに吸収されました。
各種ファイルのエントリ情報(.fnm, .doc, .posなど)
$ od -c $SOLR_HOME/collection1/data/index/_0.cfe
0000000 ? 327 l 027 031 C o m p o u n d F i l
0000020 e W r i t e r E n t r i e s \0 \0
0000040 \0 001 \t 004 . f n m \0 \0 \0 \0 \0 \0 \0 037
0000060 \0 \0 \0 \0 \0 \0 001 233 017 _ L u c e n e
0000100 4 1 _ 0 . d o c \0 \0 \0 \0 \0 \0 001 272
0000120 \0 \0 \0 \0 \0 \0 \0 S 017 _ L u c e n e
0000140 4 1 _ 0 . p o s \0 \0 \0 \0 \0 \0 002 \r
0000160 \0 \0 \0 \0 \0 \0 \0 6 004 . n v d \0 \0 \0
0000200 \0 \0 \0 002 C \0 \0 \0 \0 \0 \0 \0 * 004 . f
0000220 d x \0 \0 \0 \0 \0 \0 002 m \0 \0 \0 \0 \0 \0
0000240 \0 > 004 . n v m \0 \0 \0 \0 \0 \0 002 253 \0
0000260 \0 \0 \0 \0 \0 \0 G 017 _ L u c e n e 4
0000300 1 _ 0 . t i m \0 \0 \0 \0 \0 \0 002 362 \0
0000320 \0 \0 \0 \0 \0 001 005 017 _ L u c e n e 4
0000340 1 _ 0 . t i p \0 \0 \0 \0 \0 \0 004 L \0
0000360 \0 \0 \0 \0 \0 \0 237 004 . f d t \0 \0 \0 \0
0000400 \0 \0 003 367 \0 \0 \0 \0 \0 \0 \0 U 300 ( 223 000
0000420 \0 \0 \0 \0 \0 \0 \0 \0 9 4 302 \f
各種ファイルのデータ(FieldInfosなど)
$ od -c $SOLR_HOME/collection1/data/index/_0.cfs
0000000 ? 327 l 027 026 C o m p o u n d F i l
0000020 e W r i t e r D a t a \0 \0 \0 001 ?
0000040 327 l 027 022 L u c e n e 4 6 F i e l
0000060 d I n f o s \0 \0 \0 002 004 002 i d \0 Q
0000100 \0 377 377 377 377 377 377 377 377 \0 \0 \0 002 035 P e
0000120 r F i e l d P o s t i n g s F o
0000140 r m a t . f o r m a t \b L u c e
0000160 n e 4 1 035 P e r F i e l d P o s
0000200 t i n g s F o r m a t . s u f f
0000220 i x 001 0 004 n a m e 001 001 020 377 377 377 377
0000240 377 377 377 377 \0 \0 \0 002 035 P e r F i e l
0000260 d P o s t i n g s F o r m a t .
0000300 f o r m a t \b L u c e n e 4 1 035
0000320 P e r F i e l d P o s t i n g s
0000340 F o r m a t . s u f f i x 001 0 004
0000360 t e x t 002 001 020 377 377 377 377 377 377 377 377 \0
0000400 \0 \0 002 035 P e r F i e l d P o s t
0000420 i n g s F o r m a t . f o r m a
0000440 t \b L u c e n e 4 1 035 P e r F i
0000460 e l d P o s t i n g s F o r m a
0000500 t . s u f f i x 001 0 \t _ v e r s
0000520 i o n _ 003 Q \0 377 377 377 377 377 377 377 377 \0
0000540 \0 \0 002 035 P e r F i e l d P o s t
0000560 i n g s F o r m a t . f o r m a
0000600 t \b L u c e n e 4 1 035 P e r F i
0000620 e l d P o s t i n g s F o r m a
0000640 t . s u f f i x 001 0 300 ( 223 350 \0 \0
0000660 \0 \0 \0 \0 \0 \0 335 375 & 310 ? 327 l 027 031 L
0000700 u c e n e 4 1 P o s t i n g s W
0000720 r i t e r D o c \0 \0 \0 002 002 ! 002
0000740 # 004 005 006 \a \b \t \n \v \f \r 016 017 020 021 022
0000760 023 024 025 026 027 030 031 032 033 034 035 036 037 300 ( 223
0001000 350 \0 \0 \0 \0 \0 \0 \0 \0 257 241 320 005 ? 327 l
0001020 027 031 L u c e n e 4 1 P o s t i n
0001040 g s W r i t e r P o s \0 \0 \0 002 001
0001060 \0 001 \0 300 ( 223 350 \0 \0 \0 \0 \0 \0 \0 \0 r
0001100 336 374 * ? 327 l 027 021 L u c e n e 4 9
0001120 N o r m s D a t a \0 \0 \0 \0 300 ( 223
0001140 350 \0 \0 \0 \0 \0 \0 \0 \0 344 345 316 213 ? 327 l
0001160 027 031 L u c e n e 4 1 S t o r e d
0001200 F i e l d s I n d e x \0 \0 \0 002 002
0001220 001 \0 \0 001 \0 % \0 001 \0 \0 E 300 ( 223 350 \0
0001240 \0 \0 \0 \0 \0 \0 \0 271 X P 325 ? 327 l 027 025
0001260 L u c e n e 4 9 N o r m s M e t
0001300 a d a t a \0 \0 \0 \0 001 002 \0 \0 \0 \0 \0
0001320 \0 \0 y 002 002 \0 \0 \0 \0 \0 \0 \0 y 377 377 377
0001340 377 017 300 ( 223 350 \0 \0 \0 \0 \0 \0 \0 \0 Y L
0001360 371 222 ? 327 l 027 025 B L O C K _ T R E
0001400 E _ T E R M S _ D I C T \0 \0 \0 004
0001420 ? 327 l 027 033 L u c e n e 4 1 P o s
0001440 t i n g s W r i t e r T e r m s
0001460 \0 \0 \0 002 200 001 003 031 \v 001 024 V p 022 '
0001500 2 @ \0 \0 001 001 002 C \0 003 \t 003 U S D 001
0001520 001 002 C \0 005 027 006 d o l l a r 003 o n
0001540 e 004 001 \0 001 \0 006 C " \0 \0 001 \0 005 027 006
0001560 d o l l a r 003 o n e 004 001 \0 001 \0 006
0001600 C $ \0 \0 001 \0 004 003 001 002 222 002 001 001 001 \v
0001620 001 024 V p 022 ' 2 @ \0 \0 \v 001 024 V
0001640 p 022 ' 2 @ \0 \0 \0 001 002 336 002 001 001 001 003
0001660 U S D 003 U S D 001 002 002 212 003 002 002 001 002
0001700 006 d o l l a r 003 o n e 002 002 002 356 003
0001720 002 002 001 002 006 d o l l a r 003 o n e \0
0001740 \0 \0 \0 \0 \0 \0 224 300 ( 223 350 \0 \0 \0 \0 \0
0001760 \0 \0 \0 371 261 371 034 ? 327 l 027 030 L u c e
0002000 n e 4 1 S t o r e d F i e l d s
0002020 D a t a \0 \0 \0 002 200 200 001 002 \0 001 003 032
0002040 360 \v \0 003 U S D \b \n O n e D o l
0002060 l a r 034 024 255 300 222 v P \0 \0 300 ( 223 000
0002100 \0 \0 \0 \0 \0 \0 \0 \0 v } 376 237 ? 327 l 027
0002120 026 B L O C K _ T R E E _ T E R M
0002140 S _ I N D E X \0 \0 \0 004 ? 327 l 027 003
0002160 F S T \0 \0 \0 004 \0 001 003 002 222 002 \0 \0 \0
0002200 \0 \0 001 \0 ? 327 l 027 003 F S T \0 \0 \0 004
0002220 \0 001 003 002 336 002 \0 \0 \0 \0 \0 001 \0 ? 327 l
0002240 027 003 F S T \0 \0 \0 004 \0 001 003 003 212 002 \0
0002260 \0 \0 \0 \0 001 \0 ? 327 l 027 003 F S T \0 \0
0002300 \0 004 \0 001 003 003 356 002 \0 \0 \0 \0 \0 001 \0 037
0002320 8 Q j \0 \0 \0 \0 \0 \0 \0 203 300 ( 223 350 \0
0002340 \0 \0 \0 \0 \0 \0 \0 004 J 247 O 300 ( 223 350 \0
0002360 \0 \0 \0 \0 \0 \0 \0 S ѿ ** 9
useCompoundFile=trueでIndexのトータルサイズはどう変わる?
useCompoundFile=trueでトータルサイズが大きくなりました。
- useCompoundFile=false
fdt+fdx+fnm+nvd+nvm+doc+pos+tim+tip=1228(bytes) - useCompoundFile=true
cfs+cfe=1559(bytes)
Payloads
説明
term毎に記録される付加情報(バイト配列)で、様々な場面で利用されています。
検証
設定
schema.xmlで定義されているフィールドpayloadsを使用します。
<field name="payloads" type="payloads" indexed="true" stored="true"/>
登録用XML
$ cat test-pl.xml
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
<field name="payloads">one|1.5</field>
</doc>
</add>
dataディレクトリを削除し、solr起動
$ rm -Rf $SOLR_HOME/collection1/data
$ java -jar start.jar
ドキュメント登録
$ curl "http://localhost:8983/solr/collection1/update?commit=true" -H "Content-Type: text/xml" --data-binary @test-pl.xml
dataディレクトリを確認
$ ls -lRi $SOLR_HOME/collection1/data
total 0
28201043 drwxr-xr-x 16 mingchunzhao staff 544 1 12 13:25 index
28201047 drwxr-xr-x 3 mingchunzhao staff 102 1 12 13:25 tlog
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/index:
total 104
28201063 -rw-r--r-- 1 mingchunzhao staff 94 1 12 13:25 _0.fdt
28201059 -rw-r--r-- 1 mingchunzhao staff 62 1 12 13:25 _0.fdx
28201055 -rw-r--r-- 1 mingchunzhao staff 506 1 12 13:25 _0.fnm
28201058 -rw-r--r-- 1 mingchunzhao staff 42 1 12 13:25 _0.nvd
28201061 -rw-r--r-- 1 mingchunzhao staff 81 1 12 13:25 _0.nvm
28201060 -rw-r--r-- 1 mingchunzhao staff 352 1 12 13:25 _0.si
28201056 -rw-r--r-- 1 mingchunzhao staff 83 1 12 13:25 _0_Lucene41_0.doc
28201054 -rw-r--r-- 1 mingchunzhao staff 50 1 12 13:25 _0_Lucene41_0.pay
28201057 -rw-r--r-- 1 mingchunzhao staff 60 1 12 13:25 _0_Lucene41_0.pos
28201062 -rw-r--r-- 1 mingchunzhao staff 292 1 12 13:25 _0_Lucene41_0.tim
28201064 -rw-r--r-- 1 mingchunzhao staff 186 1 12 13:25 _0_Lucene41_0.tip
28201066 -rw-r--r-- 1 mingchunzhao staff 36 1 12 13:25 segments.gen
28201065 -rw-r--r-- 1 mingchunzhao staff 131 1 12 13:25 segments_2
28201044 -rw-r--r-- 1 mingchunzhao staff 0 1 12 13:25 write.lock
/Users/mingchunzhao/blog/solr-4.10.2/example/solr/collection1/data/tlog:
total 8
28201053 -rw-r--r-- 1 mingchunzhao staff 133 1 12 13:25 tlog.0000000000000000000
Payloads(.pay)ファイルを確認
付加的なper-positionメタデータ情報が格納されます。(character offsets、user payloadsなど)
$ od -c $SOLR_HOME/collection1/data/index/_0_Lucene41_0.pay
0000000 ? 327 l 027 031 L u c e n e 4 1 P o s
0000020 t i n g s W r i t e r P a y \0 \0
0000040 \0 002 300 ( 223 350 \0 \0 \0 \0 \0 \0 \0 \0 147 231
0000060 g 034
まとめ
これでSegmentを構成する各種ファイルタイプに対しひと通り検証が終わりました。
次回は、Indexに関係するコマンドとしてexpungeDeletesとprepareCommitを検証予定です。お楽しみに。