天天看點

solr建立多表關聯索引時子表的索引建立失敗

1、data-config.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@133.96.93.111:1521:ARS" 
              user="usddev" 
              password="usddev"/>
  <document>
    <entity name="sys_user" PK="ID"
            query="select ID,loginname,
			       nvl(fullname,'無')fullname,
			       createdate,phone,mail,fax,(case position 
				  when '0' then '員工'
				  when '1' then '組長'
				  when '2' then '處長'
				  when '3' then '副處長'
				  when '4' then '部長'
				  when '5' then '副部長'
				  when '6' then '其他'
				  when '7' then '經理'
				  when '8' then '主管'
				  when '9' then '主任'
				  else '無'
				  END) position ,  
				 (case status 
				   when 0 then '啟用'
				   when 1 then '停用'
				   else '無'
				   End
				  ) status,DEPARTID 
             from sys_user">
       <field column="id" name="id"/>
       <field column="loginname" name="loginname"/>
       <field column="fullname" name="fullname"/>
	   <field column="createdate" name="createDate"/>
	   <field column="phone" name="phone"/>
	   <field column="mail" name="mail"/>
	   <field column="fax" name="fax"/>
	   <field column="position" name="position"/>
	   <field column="status" name="status"/>
	   <field column="DEPARTID" name="departid"/>
	   <entity name="sys_group" PK="ID"
            query="select ID,
			            name,
						nvl(fullname,'無')fullname
			        from sys_group  where id ='${sys_user.DEPARTID}'">
		   <field column="name" name="groupname"/>
		   <field column="fullname" name="groupfullname"/>
		   
      </entity>
    </entity>
	
  </document>
</dataConfig>
           

2.schema.xml酣置如下:

<field name="groupname" type="mmseg4jcomplex" indexed="true" stored="true"/>
<pre name="code" class="html"> <field name="groupfullname" type="mmseg4jcomplex" indexed="true" stored="true"/>
           

3.生成的索引資料:

并沒有:groupname、groupfullname兩個字段。

原因:索引字段名稱要與資料庫字段名稱一緻,如果兩個表有相同的字段名則要在字段後加   multiValued="true"

解決:

1.data-config.xml 修改如下:

solr建立多表關聯索引時子表的索引建立失敗

2.schema.xml修改如下:

solr建立多表關聯索引時子表的索引建立失敗

然後重新啟動solr并重新生成索引檔案。

生成的結果如下:

solr建立多表關聯索引時子表的索引建立失敗

繼續閱讀