幾個小時後......首先,在這個問題上有很多誤導,錯誤和無用的信息。沒有網頁似乎在一個地方提供了一切。所有這些信息都是有意爲之,但是在不同的版本之間,有些則超出了我的頭腦,但並沒有解決問題。這裏是我學到的東西和解決方案的集合。 重申,我使用的是Solr 4.0(在Tomcat上)+ Oracle 11g。
解決方案概述:DataImportHandler + TikaEntityProcessor + FieldStreamDataSource
步驟1,請確保您更新solrconfig.xml
,這樣的Solr可以找到TikaEntityProcessor + DataImportHandler + Solr的細胞東西。
<lib dir="../contrib/dataimporthandler/lib" regex=".*\.jar" />
<!-- will include extras (where TikaEntPro is) and regular DIH -->
<lib dir="../dist/" regex="apache-solr-dataimporthandler-.*\.jar" />
<lib dir="../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../dist/" regex="apache-solr-cell-\d.*\.jar" />
步驟2,修改data-config.xml
,包括您的BLOB表。這是我遇到最多麻煩的地方,因爲這個問題的解決方案已經改變很多,因爲版本已經改變。另外,使用多個數據源並將它們正確地連接在一起對我而言並不直觀。一旦完成,非常光滑。請務必在此更換你的IP,SID名,用戶名,密碼,表名等
<dataConfig>
<dataSource name="dastream" type="FieldStreamDataSource" />
<dataSource name="db" type="JdbcDataSource"
driver="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.1.1.1:1521:sid"
user="username"
password="password"/>
<document>
<entity
name="attachments"
query="select * from schema.attachment_table"
dataSource="db">
<entity
name="attachment"
dataSource="dastream"
processor="TikaEntityProcessor"
url="blob_column"
dataField="attachments.BLOB_COLUMN"
format="text">
<field column="text" name="body" />
</entity>
</entity>
<entity name="unrelated" query="select * from another_table" dataSource="db">
</entity>
</document>
</dataConfig>
的重要注意事項。如果您在嘗試導入時出現"No field available for name : whatever"
錯誤,則FieldStreamDataSource無法解析您提供的數據字段名稱。對於我來說,我必須將url
屬性設置爲小寫字母名稱,然後將dataField
屬性設置爲outside_entity_name.UPPERCASE_BLOB_COLUMN。此外,一旦我的列名錯誤,這也會導致問題。
步驟3,您需要修改schema.xml
以添加BLOB列字段(以及需要索引/存儲的任何其他列)。根據您的需求進行修改。
<field name="body" type="text_en" indexed="false" stored="false" />
<field name="attach_desc" type="text_general" indexed="true" stored="true" />
<field name="text" type="text_en" indexed="true" stored="false" multiValued="true" />
<field name="content" type="text_general" indexed="false" stored="true" multiValued="true" />
<copyField source="body" dest="text" />
<copyField source="body" dest="content" />
有了,你應該用自己的方式來節省很多時間讓被存儲在使用Solr索引的數據庫列的BLOB二進制文件,富文本文件(又名豐富的文檔)。
我怎麼沒有找到這個?無論如何,我會看看我是否可以把這個工作,如果是的話,我會回來接受。謝謝 – DarkerIvy 2013-03-01 20:09:46