【问题标题】:Why does the Solr Data Import Handler hashes the uniqueKey?为什么 Solr 数据导入处理程序对 uniqueKey 进行哈希处理?
【发布时间】:2014-02-12 10:50:34
【问题描述】:

我对 Solr 4.6.0 有一个非常奇怪的问题。

uniqueKey 字段“id”包含每个文档的哈希值,而不是我的字符串值。如果在 Solr 管理员中仅使用更新请求处理程序添加一个自定义文档,我会得到例如我指定的 ID 值“book_45”,这是正确的。

但是当我使用 DIH(数据导入处理程序)进行完全导入时,id 字段包含每个文档的哈希值,例如“[B@53bd370f”,而不是我的自定义值。所以问题一定出在DIH上。

我的导入脚本:

<dataConfig>
<dataSource
    type="JdbcDataSource"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://host/database"
    user="user"
    password="password" />
<document name="project">
    <entity name="document" transformer="RegexTransformer"
        query="SELECT CONCAT('book_', b.id) AS book_id, b.slug, b.title, b.isbn,
                b.publisher, b.releaseYear AS release_year, b.language, b.pageCount AS page_count, b.description,
                b.print, b.addedBy_id AS added_by_id, b.dt AS created,
                GROUP_CONCAT(a.name SEPARATOR ';') AS authors
            FROM Book b
            LEFT JOIN author_book ab ON ab.book_id = b.id
            LEFT JOIN Author a ON a.id = ab.author_id
            GROUP BY b.id
            ">
        <field column="book_id" name="id" />
        <field column="slug" name="book_slug" />
        <field column="title" name="book_title" />
        <field column="isbn" name="book_isbn" />
        <field column="publisher" name="book_publisher" />
        <field column="release_year" name="book_release_year" />
        <field column="language" name="book_language" />
        <field column="page_count" name="book_page_count" />
        <field column="description" name="book_description" />
        <field column="print" name="book_print" />
        <field column="added_by_id" name="book_added_by_id" />
        <field column="created" name="book_created" />
        <field column="authors" splitBy=";" name="authors" />
    </entity>
</document>

我的 schema.xml 中的 id 字段(与默认发布的核心集合 1 中的相同):

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<uniqueKey>id</uniqueKey>

有人知道我错过了什么吗?

【问题讨论】:

    标签: solr dih


    【解决方案1】:

    [B@53bd370f 不是哈希,而是 byte[].toString() 的结果。 Mysql 返回的任何内容都被视为 byte[] 而不是 String。

    尝试将 id 转换为 varchar 或 char,如下所示:

     SELECT cast(CONCAT('book_', b.id) as CHAR) AS book_id...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多