Solr - 嵌套实体需要返回两个值

时间:2012-10-15 12:25:19

标签: solr

遵循实体定义:

<entity name="mission" dataSource="mssqlDatasource" pk="id" 
        transformer="TemplateTransformer, ClobTransformer" 
        query="SELECT m.id, m.notes, m.missionFocus,m.start_time, 
                      mar.id AS market, mar.name AS marketName 
               FROM mission m 
               INNER JOIN market mar ON m.market = mar.id">

    <field column="start_time" name="startTime" />
    <field column="market" name="market" />
    <field column="marketName" name="marketName" clob="true" />
    <field column="tableType" template="MISSION" />

    <entity name="comment" dataSource="mssqlDatasource" 
            transformer="ClobTransformer" 
            query="SELECT c.message 
                   FROM comment c 
                   WHERE c.source_id = '${mission.id}' AND c.source_type = 'mission'">
        <field name="commentMessage" column="message" clob="true" />
    </entity>

    <entity name="activity" dataSource="mssqlDatasource" 
            query="SELECT a.notes 
                   FROM activity a 
                   WHERE a.mission = '${mission.id}'">
        <field name="activityNotes" column="notes" />
    </entity>        

    <entity name="location" dataSource="mssqlDatasource" 
                query="SELECT l.name 
                       FROM location l 
                       WHERE l.id = '${activity.id}'">
        <field name="locationName" column="name" />            
    </entity>        
</entity>

你看我的问题是嵌套实体'activity'需要返回2个字段,即'activityNotes'和来自嵌套实体'location'的字段,即'locationName'。我怎么能意识到这一点?这两个字段都应该被编入索引..只有机会对这两个字符串进行COALESCE吗?

1 个答案:

答案 0 :(得分:0)

你可以在ScriptUpdateProcessor中完成。您只需从DIH中的不同字段中获取它们,但在UpdateProcessor中,您可以将它们附加到第三个字段中。在4.0中,您应该可以在没有ScriptUpdateProcessor的

的Java代码的情况下执行此操作