如何在Solr索引中存储特殊字符?

时间:2015-03-01 15:34:18

标签: mysql solr

我需要在Solr索引中存储特殊字符。 我将尝试索引包含Solr特殊字符的mysql数据库,但是当我在生成的索引中搜索时,特殊字符的存储方式如下:�。

配置文件包括:

数据-config.xml中

<dataConfig>
    <dataSource type="JdbcDataSource" 
        encoding="UTF-8"
        URIEncoding="UTF-8"
        driver="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://localhost:3306/db_name"
        user="***" 
        password="***" />

    <document name="content">
        <entity name="id" query="SELECT * FROM organization"
            deltaImportQuery="SELECT * FROM organization" deltaQuery="SELECT * FROM organization">
            <field column="organization_id" name="organization_id" />
            <field column="name" name="name" />
            <field column="cb_url" name="cb_url" />
            <field column="cb_image_url" name="cb_image_url" />
            <field column="fb_url" name="fb_url" />
            <field column="tw_url" name="tw_url" />
            <field column="ln_url" name="ln_url" />
            <field column="city" name="city" />
            <field column="region" name="region" />
            <field column="state" name="state" />
            <field column="cb_description" name="cb_description" />
            <field column="last_change_date" name="last_change_date" />
            <field column="al_id" name="al_id" />
            <field column="al_url" name="al_url" />
            <field column="al_followers" name="al_followers" />
            <field column="al_pre_money_valuation" name="al_pre_money_valuation" />
            <field column="al_raising_amount" name="al_raising_amount" />
            <field column="al_blog_url" name="al_blog_url" />
            <field column="fb_name" name="fb_name" />
            <field column="fb_id" name="fb_id" />
            <field column="fb_about" name="fb_about" />
            <field column="fb_companyoverview" name="fb_companyoverview" />
            <field column="fb_checkins" name="fb_checkins" />
            <field column="fb_founded" name="fb_founded" />
            <field column="fb_likes" name="fb_likes" />
            <field column="fb_latitude" name="fb_latitude" />
            <field column="fb_longitude" name="fb_longitude" />
            <field column="fb_street" name="fb_street" />
            <field column="fb_talkingabout" name="fb_talkingabout" />
            <field column="ln_name" name="ln_name" />
            <field column="ln_id" name="ln_id" />
            <field column="ln_companytype" name="ln_companytype" />
            <field column="ln_industries" name="ln_industries" />
            <field column="ln_status" name="ln_status" />
            <field column="ln_blogrssurl" name="ln_blogrssurl" />
            <field column="ln_employeecountrange" name="ln_employeecountrange" />
            <field column="ln_specialties" name="ln_specialties" />
            <field column="ln_description" name="ln_description" />
            <field column="ln_endyear" name="ln_endyear" />
            <field column="ln_numfollowers" name="ln_numfollowers" />
            <field column="tw_name" name="tw_name" />
            <field column="tw_id" name="tw_id" />
            <field column="tw_followers" name="tw_followers" />
            <field column="tw_friendscount" name="tw_friendscount" />
            <field column="tw_favouritescount" name="tw_favouritescount" />
            <field column="tw_statusescount" name="tw_statusescount" />
        </entity>
    </document>
</dataConfig>

schema.xml中

<schema>
    <fieldType name="text_split" class="solr.TextField">
        <analyzer>
            <tokenizer class="solr.WhitespaceTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
        </analyzer>
    </fieldType>

    <field name="organization_id" type="string" indexed="true"
        stored="true" required="true" />
    <field name="name" type="text_general" indexed="true" stored="true" />
    <field name="cb_description" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_about" type="text_split" indexed="true" stored="true" />
    <field name="fb_companyoverview" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_description" type="text_split" indexed="true"
        stored="true" />

    <field name="cb_url" type="text_split" indexed="true" stored="true" />
    <field name="cb_image_url" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_url" type="text_split" indexed="true" stored="true" />
    <field name="tw_url" type="text_split" indexed="true" stored="true" />
    <field name="ln_url" type="text_split" indexed="true" stored="true" />
    <field name="city" type="text_split" indexed="true" stored="true" />
    <field name="region" type="text_split" indexed="true" stored="true" />
    <field name="state" type="text_split" indexed="true" stored="true" />
    <field name="last_change_date" type="text_split" indexed="true"
        stored="true" />
    <field name="al_id" type="text_split" indexed="true" stored="true" />
    <field name="al_url" type="text_split" indexed="true" stored="true" />
    <field name="al_followers" type="text_split" indexed="true"
        stored="true" />
    <field name="al_pre_money_valuation" type="text_split" indexed="true"
        stored="true" />
    <field name="al_raising_amount" type="text_split" indexed="true"
        stored="true" />
    <field name="al_blog_url" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_name" type="text_split" indexed="true" stored="true" />
    <field name="fb_id" type="text_split" indexed="true" stored="true" />
    <field name="fb_checkins" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_founded" type="text_split" indexed="true" stored="true" />
    <field name="fb_likes" type="text_split" indexed="true" stored="true" />
    <field name="fb_latitude" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_longitude" type="text_split" indexed="true"
        stored="true" />
    <field name="fb_street" type="text_split" indexed="true" stored="true" />
    <field name="fb_talkingabout" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_name" type="text_split" indexed="true" stored="true" />
    <field name="ln_id" type="text_split" indexed="true" stored="true" />
    <field name="ln_companytype" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_industries" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_status" type="text_split" indexed="true" stored="true" />
    <field name="ln_blogrssurl" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_employeecountrange" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_specialties" type="text_split" indexed="true"
        stored="true" />
    <field name="ln_endyear" type="text_split" indexed="true" stored="true" />
    <field name="ln_numfollowers" type="text_split" indexed="true"
        stored="true" />
    <field name="tw_name" type="text_split" indexed="true" stored="true" />
    <field name="tw_id" type="text_split" indexed="true" stored="true" />
    <field name="tw_followers" type="text_split" indexed="true"
        stored="true" />
    <field name="tw_friendscount" type="text_split" indexed="true"
        stored="true" />
    <field name="tw_favouritescount" type="text_split" indexed="true"
        stored="true" />
    <field name="tw_statusescount" type="text_split" indexed="true"
        stored="true" />
</schema>

0 个答案:

没有答案