ExtractingRequestHandler の問題
ExtractingRequestHandler で PDF を Solr にポストすると、本文 (content
) の冒頭部分にメタデータが追加されてしまう。
例えば この PDF だと、content
の冒頭は以下のようになる。
dcterms:modified 2003-08-15T05:59:59Z
meta:creation-date 2003-08-15T01:45:32Z
meta:save-date 2003-08-15T05:59:59Z
dc:creator ldefurio
Last-Modified 2003-08-15T05:59:59Z
dcterms:created 2003-08-15T01:45:32Z
Author ldefurio
date 2003-08-15T05:59:59Z
modified 2003-08-15T05:59:59Z
creator ldefurio
xmpTPg:NPages 10
Creation-Date 2003-08-15T01:45:32Z
meta:author ldefurio
stream_content_type application/pdf
created Fri Aug 15 10:45:32 JST 2003
stream_size 421485
producer Acrobat Distiller 6.0 (Windows)
Content-Type application/pdf
xmp:CreatorTool FrameMaker 7.0
Last-Save-Date 2003-08-15T05:59:59Z
dc:title Samples.book
こんなメタデータが、検索時のスニペットに表示されてしまい、嬉しくない。
回避方法
にあるように、captureAttr
を true に設定すると直るみたい。なんでこれで直るのかは不明。バグっぽい。
captureAttr
はドキュメントによると、Tika XHTML の XML 属性値を、個々のフィールドにセットするかどうかを指定する値。
属性をフィールドに設定しない (false
) 場合は、代わりに content
に含めるってことなのかも?でも、
- 属性をフィールドに設定するかどうか
- 属性を content に含めるかどうか
は、別々に制御できてほしい気がする。というか後者が便利なことってあるかなー。
メタデータは、Solr ではどんな名前のフィールドに設定されるか
uprefix
を attr_
とすると、以下のような値が Solr のドキュメントに設定されていた。
"attr_meta": [
"dcterms:modified",
"2003-08-15T05:59:59Z",
"meta:creation-date",
"2003-08-15T01:45:32Z",
"meta:save-date",
"2003-08-15T05:59:59Z",
"dc:creator",
"ldefurio",
"Last-Modified",
"2003-08-15T05:59:59Z",
"dcterms:created",
"2003-08-15T01:45:32Z",
"Author",
"ldefurio",
"date",
"2003-08-15T05:59:59Z",
"modified",
"2003-08-15T05:59:59Z",
"creator",
"ldefurio",
"xmpTPg:NPages",
"10",
"Creation-Date",
"2003-08-15T01:45:32Z",
"meta:author",
"ldefurio",
"stream_content_type",
"application/pdf",
"created",
"Fri Aug 15 10:45:32 JST 2003",
"stream_size",
"421485",
"producer",
"Acrobat Distiller 6.0 (Windows)",
"Content-Type",
"application/pdf",
"xmp:CreatorTool",
"FrameMaker 7.0",
"Last-Save-Date",
"2003-08-15T05:59:59Z",
"dc:title",
"Samples.book"
],
"attr_div": [
"page",
"page",
"page",
"page",
"page",
"annotation",
"annotationTitle",
"annotationSubject",
"annotationContents",
"page",
"page",
"page",
"page",
"page"
],
"attr_dcterms_modified": [
"2003-08-15T05:59:59Z"
],
"attr_meta_creation_date": [
"2003-08-15T01:45:32Z"
],
"attr_meta_save_date": [
"2003-08-15T05:59:59Z"
],
"attr_dc_creator": [
"ldefurio"
],
"attr_last_modified": [
"2003-08-15T05:59:59Z"
],
"attr_dcterms_created": [
"2003-08-15T01:45:32Z"
],
"attr_date": [
"2003-08-15T05:59:59Z"
],
"attr_modified": [
"2003-08-15T05:59:59Z"
],
"attr_creator": [
"ldefurio"
],
"attr_xmptpg_npages": [
"10"
],
"attr_creation_date": [
"2003-08-15T01:45:32Z"
],
"attr_meta_author": [
"ldefurio"
],
"attr_stream_content_type": [
"application/pdf"
],
"attr_created": [
"Fri Aug 15 10:45:32 JST 2003"
],
"attr_stream_size": [
"421485"
],
"attr_producer": [
"Acrobat Distiller 6.0 (Windows)"
],
"attr_xmp_creatortool": [
"FrameMaker 7.0"
],
"attr_last_save_date": [
"2003-08-15T05:59:59Z"
],
"attr_dc_title": [
"Samples.book"
],
PDF のメタデータを検索対象にしたいときは、content
ではなくこちらを使う。
確認に使った Solr のバージョン
4.6.0