对于oracl中的clob字段,solr建立索引时,如果没有作处理,否则会展示成这样。
<content>oracle.sql.CLOB@1723c20</content>
需要在db-data-config.xml中加入如下红色的部分:
transformer="ClobTransformer"
<field column="CONTENT" name="content" clob="true" />
- <dataConfig>
- <dataSource type="JdbcDataSource" name="jdbc" driver="oracle.jdbc.driver.OracleDriver"
- url="jdbc:oracle:thin:@//*.*.*.*:port/orcl" user="root" password="root"/>
- <document>
- <entity name="item" transformer="ClobTransformer" query="select ID as id,NAME as name,PRICE as price,
- SUMMARY as summary,CONTENT as content from BOOK"
- <field column="CONTENT" name="content" clob="true" />
- </entity>
- </document>
- </dataConfig>
这个field的column一定要写成大写的CONTENT,要不然转换不了。
在schema.xml中添加需要检索的field
- <fields>
- <field name="id" type="string" indexed="true" stored="true" required="true" />
- <field name="name" type="textMaxWord_cn" indexed="true" stored="true" />
- <field name="price" type="long" indexed="true" stored="true" />
- <field name="summary" type="textMaxWord_cn" indexed="true" stored="true" />
- <field name="content" type="textMaxWord_cn" indexed="true" stored="true" />
- <field name="searchText" type="textMaxWord_cn" indexed="true" stored="false" multiValued="true" />
- </fields>
-
- <uniqueKey>id</uniqueKey>
- <defaultSearchField>searchText</defaultSearchField>
- <solrQueryParser defaultOperator="AND" />
- <copyField source="name" dest="searchText" />
- <copyField source="summary" dest="searchText" />
- <copyField source="content" dest="searchText" />