1

我是 Solr 的新手,无法弄清楚为什么 Delta 导入什么都不做,而完全导入却可以正常工作。每当我运行 Delta-import 时,我都会得到相同的响应,但没有提及添加任何新文档。每当编辑/添加该行时,该updated_at列就存在并且包含正确的。timestamp

我是否错过了让 Delta 导入工作所需的东西?

的输出http://domain.com:8080/solr/dataimport?command=delta-import

<response>
    <lst name="responseHeader">
        <int name="status">0</int>
        <int name="QTime">104</int>
    </lst>
    <lst name="initArgs">
        <lst name="defaults">
            <str name="config">/usr/local/solr/conf/data-config.xml</str>
        </lst>
    </lst>
    <str name="command">delta-import</str>
    <str name="status">idle</str>
    <str name="importResponse"/>
    <lst name="statusMessages">
        <str name="Total Requests made to DataSource">1</str>
        <str name="Total Rows Fetched">0</str>
        <str name="Total Documents Skipped">0</str>
        <str name="Delta Dump started">2012-08-24 01:55:07</str>
        <str name="Identifying Delta">2012-08-24 01:55:07</str>
        <str name="Deltas Obtained">2012-08-24 01:55:07</str>
        <str name="Building documents">2012-08-24 01:55:07</str>
        <str name="Total Changed Documents">0</str>
        <str name="Total Documents Processed">0</str>
        <str name="Time taken">0:0:0.9</str>
    </lst>
    <str name="WARNING">
        This response format is experimental. It is likely to change in the future.
    </str>
</response>

数据配置.xml

<dataConfig>

    <dataSource 
        name="mysql"
        driver="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://localhost/mysite" 
        user="myuser" 
        password="mypassword" />

    <document>
        <entity 
            name="posts" 
            datasource="mysql"
            query="select id, title, description from posts"
            deltaQuery="select id from posts where updated_at > '${dataimporter.last_index_time}'"
            deltaImportQuery="select id, title, description from posts where id='${dataimporter.delta.id}'">
        </entity>
        <field column="id" name="id" indexed="true" stored="true" />
        <field column="title" name="title" indexed="true" stored="true" />
        <field column="description" name="description" indexed="true" stored="true" />
    </document>

</dataConfig>
4

1 回答 1

1

尝试更改文档的结构,用实体元素包围字段元素,并为实体添加主键属性:

<entity 
    name="posts"
    pk="id"
    datasource="mysql"
    query="select id, title, description from posts"
    deltaQuery="select id from posts where updated_at > '${dataimporter.last_index_time}'"
    deltaImportQuery="select id, title, description from posts where id='${dataimporter.delta.id}'">
  <field column="id" name="id" indexed="true" stored="true" />
  <field column="title" name="title" indexed="true" stored="true" />
  <field column="description" name="description" indexed="true" stored="true" />    
</entity>
于 2012-08-24T02:37:43.823 回答