solr导入配置规则总结
程序员文章站
2022-06-22 17:05:49
...
<dataConfig> <dataSource type="JdbcDataSource" driver="dm.jdbc.driver.DmDriver" url="jdbc:dm://172.16.17.68:5236/DMSERVER" user="BSS_DEV" password="123456789" /> <document name="index"> <entity name="indexBean" pk="id" transformer="ClobTransformer,RegexTransformer" query="select id, busi_id, title, CONTENT, filenames, url, datatime,secret_level,appid, moduleid, state from solr_index"> <field column="id" name="id" /> <field column="title" name="title" /> <field column="CONTENT" name="content" clob="true"/><!-- CONTENT必须大写 --> <field column="fileNames" splitBy="," sourceColName="FILENAMES"/> <!-- FILENAMES必须大写 --> <field column="url" name="url" /> <field column="datatime" name="dataTime" /> <field column="secret_level" name="secretLevel" /> <field column="appid" name="appId" /> <field column="moduleid" name="moduleId" /> <entity name="users" query="select user_id from solr_index_users where index_id = '${indexBean.ID}'"> <field column="USER_ID" name="userIds" /><!-- USER_ID必须大写 --> </entity> <entity name="orgs" query="select org_id from solr_index_orgs where index_id = '${indexBean.ID}'"> <field column="ORG_ID" name="orgIds" /> </entity> <entity name="keywords" query="select keyword_name||':'||keyword_value keyword_v from solr_index_keyword where index_id = '${indexBean.ID}'"> <field column="KEYWORD_V" name="keyword" /> </entity> </entity> </document> </dataConfig>
<fields> <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="title" type="text" indexed="true" stored="true" /> <field name="keyword" type="text" indexed="true" stored="true" multiValued="true"/> <field name="content" type="text" indexed="true" stored="true" /> <field name="fileNames" type="text" indexed="true" stored="true" multiValued="true"/> <field name="url" type="string" indexed="false" stored="true"/> <field name="dataTime" type="date" indexed="true" stored="true"/> <field name="secretLevel" type="string" indexed="true" stored="true"/> <field name="orgIds" type="string" indexed="true" stored="true" multiValued="true"/> <field name="userIds" type="string" indexed="true" stored="true" multiValued="true"/> <field name="appId" type="string" indexed="true" stored="true"/> <field name="moduleId" type="string" indexed="true" stored="true"/> <field name="all" type="text" indexed="true" stored="false"/> </fields> <copyField source="title" dest="all"/> <copyField source="keyword" dest="all"/> <copyField source="content" dest="all"/> <copyField source="fileNames" dest="all"/> <uniqueKey>id</uniqueKey> <defaultSearchField>all</defaultSearchField> <solrQueryParser defaultOperator="AND" />
1:entity.transformer的值是转换器类 如果有两个用逗号分开
ClobTransformer 处理clob
RegexTransformer 处理 正则
2:field.column,field.sourceColName中的值如果需要转换器调用,就需要大写,
3:如果field.column 与 field.name 是多对一的关系, 也需要大写
<entity name="users" query="select user_id from solr_index_users where index_id = '${indexBean.ID}'">
<field column="USER_ID" name="userIds" /><!-- USER_ID必须大写 -->
</entity>
4:entity.query中sql 占位符的列部分也需要大写${indexBean.ID}
-----fk 调了1,2个小时,不记录下来浪费了。