1

我在这里看到了一些关于为相应的 MySQL 列数据类型选择正确的字段类型的问题,但我的问题有点奇怪。我在 MySQL 类型的帖子中有一个专栏text,我已经尝试field-type在 Solr 中对应它,schema.xml例如string, text, text-ws。但每当我使用 DIH 导入它时,它都会作为 BLOB 对象导入。我检查了一下,这件事只发生在类型列text而不是varchar(它们被索引为字符串)。因此,posts 字段无法搜索。

在反复搜索失败后,我*:*在 Solr 上进行查询搜索时发现了这个问题。示例响应:

    <result name="response" numFound="223" start="0" maxScore="1.0">
    <doc>
    <float name="score">1.0</float>
    <str name="solr_post_bio">[B@10a33ce2</str>
    <date name="solr_post_created_at">2011-02-21T07:02:55Z</date>
    <str name="solr_post_email">test.account@gmail.com</str>
    <str name="solr_post_first_name">Test</str>
    <str name="solr_post_last_name">Account</str>
    <str name="solr_post_message">[B@2c93c4f1</str>
    <str name="solr_post_status_message_id">1</str>
    </doc>

编辑 :

为未提供以下详细信息而道歉。

data-config.xml:_

    <document>
    <entity name="posts" dataSource="jdbc"  query="select 
        p.person_id as solr_post_person_id,
        pr.first_name as solr_post_first_name,
        pr.last_name as solr_post_last_name,
        u.email as solr_post_email,
        p.message as solr_post_message,
        p.id as solr_post_status_message_id,
        p.created_at as solr_post_created_at,
        pr.bio as solr_post_bio
        from posts p,users u,profiles pr where p.person_id = u.id and p.person_id = pr.person_id and p.type='StatusMessage'">               
            <field column="solr_post_person_id" />
        <field column="solr_post_first_name"/>
        <field column="solr_post_last_name" />
        <field column="solr_post_email" />
        <field column="solr_post_message" />
        <field column="solr_post_status_message_id" />
        <field column="solr_post_created_at" />
        <field column="solr_post_bio"/>
       </entity>
  </document>

schema.xml:_

<fields>
    <field name="solr_post_status_message_id" type="string" indexed="true" stored="true" required="true" />
    <field name="solr_post_message" type="text_ws" indexed="true" stored="true" required="true" />  
    <field name="solr_post_bio" type="text" indexed="false" stored="true" />
    <field name="solr_post_first_name" type="string" indexed="false" stored="true" />
    <field name="solr_post_last_name" type="string" indexed="false" stored="true" />
    <field name="solr_post_email" type="string" indexed="false" stored="true" />
    <field name="solr_post_created_at" type="date" indexed="false" stored="true" />
</fields>
<uniqueKey>solr_post_status_message_id</uniqueKey>
<defaultSearchField>solr_post_message</defaultSearchField>
4

1 回答 1

0

我有同样的问题。我所有的配置和模式都是正确的,但我仍然在一个简短的文本字段中得到 blob。

经过一番摸索,我终于偶然发现了这个交流:http: //qnalist.com/questions/624892/solr-dih-importing-mysql-text-column-as-a-blob

事实证明,MySQL 或 JDBC 中存在一个错误,导致 CHAR 或 VARCHAR 字段在极少数情况下显示为 BLOB。我怀疑这个错误与 MySQL 有关,因为我正在使用一个相当旧的版本。

就我而言,解决方法是将值包装在 CONCAT() 中,然后将其包装CAST() 中。这最终使 MySQL 确信,是的,我的文本列确实是文本。

CAST(CONCAT('',your_column) AS CHAR(20))

我不知道你是否找到了解决问题的方法,但是当我遇到它时,这个页面经常出现在我的谷歌搜索中,所以我希望下一个可怜的灵魂会发现这篇文章有帮助。

于 2015-05-18T20:16:42.157 回答