splitting multivalued field while importing data i

2019-05-23 02:37发布

问题:

I'm having a bit of trouble getting my head around solr 3.4 when it comes to multiple values. I have this DIH:

<dataConfig>
    <dataSource type="JdbcDataSource" name="********" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lokal" user="****" password="******" />
    <document>
        <entity name="Search" transformer="RegexTransformer" query="select b_id, b_navn, b_cats, b_info, b_keyword, b_critical, b_geo, b_adress from searchbiz">
            <field column="b_id" name="b_id" />
            <field column="b_info" name="b_info" />
            <field column="b_cats" name="b_cats" splitBy=","/>
        </entity>
    </document>
</dataConfig>

Now, my problem is when this b_cats is index'ed Im getting this result :

<arr name="b_adress">
  <str>place1, place2</str>
</arr>

But I thought it should be one node on each.

When I try to facet using this field, I'm getting "place1, place2" = xx result, instead of place1 = xx, and place2 xx.

Can anybody please point me in the right direction on this problem?

Thanks ;)

回答1:

Here is the solution:

<dataConfig>
<dataSource type="JdbcDataSource" name="********" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lokal"     user="****" password="******" />
<document>
    <entity name="Search" transformer="RegexTransformer" query="select b_id, b_navn, b_cats, b_info, b_keyword, b_critical,     b_geo, b_adress from searchbiz">
        <field column="b_id" name="b_id" />
        <field column="b_info" name="b_info" />
        <field column="b_cats" splitBy="," sourceColName="b_cats"/>
    </entity>
</document>