solr创建一对多的索引

db-data-config.xml文件的写法

<dataConfig>
    <dataSource driver="org.hsqldb.jdbcDriver"
    url="jdbc:mysql://abc.com:3306/databaseName?useUnicode=true&amp;characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false&amp;serverTimezone=Asia/Shanghai&amp;autoReconnect=true&amp;failOverReadOnly=false"
    USER="username" password="asdf"/>
    <document>
        <entity name="meeting" pk="id" transformer="DateFormatTransformer,HTMLStripTransformer,LogTransformer"
            query="select a.id, user_id, title, content, riqi, start_time, end_time, department, applicant, name
                    from yd_meeting a join yd_meeting_room b on a.room_id = b.id where a.status = 0"

            deltaImportQuery="select a.id, user_id, title, content, riqi, start_time, end_time, department, applicant, name
                    from yd_meeting a join yd_meeting_room b on a.room_id = b.id where a.status = 0 and a.id = '${dih.delta.id}' "

            deletedPkQuery="SELECT id FROM yd_meeting where status = 1 "  
            deltaQuery="select id from yd_meeting where status = 0 and update_time &gt; '${dih.last_index_time}'"
        >
            <FIELD COLUMN="id" name="id" />
            <FIELD COLUMN="user_id" name="ownerUserId" />
            <FIELD COLUMN="title" name="title" />
            <FIELD COLUMN="content" name="content" stripHTML="true"/>
            <FIELD COLUMN="riqi" name="riqi" />
            <FIELD COLUMN="start_time" name="startTime" />
            <FIELD COLUMN="end_time" name="endTime" />
            <FIELD COLUMN="department" name="department" />
            <FIELD COLUMN="applicant" name="applicant"/>
            <FIELD COLUMN="name" name="roomName"/>
           
            <entity name="summary" query="select id, user_id, content from yd_meeting_summary where meeting_id = '${meeting.id}'">
                <FIELD COLUMN="id" name="summaryId" />
                <FIELD COLUMN="user_id" name="summaryUserId" />
                <FIELD COLUMN="content" name="summaryContent" />
            </entity>
            <entity name="user" query="select id, user_id from yd_re_meeting_user where meeting_id = '${meeting.id}' and status = 0"
                deltaImportQuery="select id, user_id from yd_re_meeting_user where id = '${dih.delta.id}' "
                deletedPkQuery="SELECT id FROM yd_re_meeting_user where status = 1 "  
                deltaQuery="select id from yd_re_meeting_user where status = 0 and update_time &gt; '${dih.last_index_time}'"
            >
                <FIELD COLUMN="user_id" name="userId" />
            </entity>
        </entity>
       
    </document>
</dataConfig>

managed-schema文件的写法

<field name="title" type="text_cn" indexed="true" stored="true" />
<field name="username" type="string" indexed="true" stored="true" />
<field name="content" type="text_cn" indexed="true" stored="true" />
<field name="ownerUserId"  type="string" indexed="true" stored="true" />
<field name="riqi"  type="string" indexed="true" stored="true" />
<field name="startTime"  type="string" indexed="true" stored="true" />
<field name="endTime"  type="string" indexed="true" stored="true" />
<field name="department"  type="string" indexed="false" stored="true" />
<field name="applicant" type="string" indexed="false" stored="true" />
<field name="roomName" type="string" indexed="false" stored="true" />
<field name="summaryUserId"  type="string" indexed="true" stored="true" multiValued="true"/>
<field name="summaryContent"  type="text_cn" indexed="true" stored="true" multiValued="true"/>
<field name="userId"  type="string" indexed="true" stored="true" multiValued="true"/>

重点:
multiValued=”true”

发表评论

电子邮件地址不会被公开。 必填项已用*标注