Solr delta-import删除索引

时间:2016-05-01 03:12:29

标签: solr solr4 dataimporthandler

我在使用MySQL数据库进行Solr delta-import时遇到问题。我能够完全导入没问题。当我尝试进行delta-import时,它会导入已更改的记录(如预期的那样),但会清除索引的其余部分,以便只有更新的记录在索引中。日志中没有错误。我在配置中遗漏了什么吗?在Ubuntu服务器上运行Solr 5.4并使用管理UI。

<dataConfig>
    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/ibnet" user="xxxx" password="xxxxx" />
    <document>
    <entity name="profile" pk="profile.id" query="
        SELECT 
            profile.id AS id,
            profile.profile_status AS profile_status,
            //
            // Other fields
            //
            linkedProfile.org_name AS linked_org_name,
            linkedProfile.org_city AS linked_org_city,
            linkedProfile.org_st_prov_reg AS linked_org_st_prov_reg,
            linkedProfile.org_country AS linked_org_country
        FROM profile AS profile
        LEFT JOIN profile AS linkedProfile ON linkedProfile.id = profile.linked_id" 
        deltaImportQuery="
            SELECT 
                profile.id AS id,
                profile.profile_status AS profile_status,
                //
                // Other fields
                //
                linkedProfile.org_name AS linked_org_name,
                linkedProfile.org_city AS linked_org_city,
                linkedProfile.org_st_prov_reg AS linked_org_st_prov_reg,
                linkedProfile.org_country AS linked_org_country
            FROM profile AS profile
            LEFT JOIN profile AS linkedProfile ON linkedProfile.id = profile.linked_id
            WHERE profile.id = '${dih.delta.id}'"
        deltaQuery="SELECT profile.id FROM profile WHERE last_modified > '${dih.last_index_time}'"
        onError="skip" >
    </entity>
</document>

编辑:我已将dih.delta.id更改为dataimporter.delta.id,并将其更改为last_index_time,但这并未改变结果。

以下是回复:

{
  "responseHeader": {
    "status": 0,
    "QTime": 0
  },
  "initArgs": [
    "defaults",
    [
      "config",
      "data-config.xml"
    ]
  ],
  "command": "status",
  "status": "idle",
  "importResponse": "",
  "statusMessages": {
    "Total Requests made to DataSource": "4",
    "Total Rows Fetched": "6",
    "Total Documents Processed": "3",
    "Total Documents Skipped": "0",
    "Delta Dump started": "2016-05-01 02:38:03",
    "Identifying Delta": "2016-05-01 02:38:03",
    "Deltas Obtained": "2016-05-01 02:38:03",
    "Building documents": "2016-05-01 02:38:03",
    "Total Changed Documents": "3",
    "": "Indexing completed. Added/Updated: 3 documents. Deleted 0 documents.",
    "Committed": "2016-05-01 02:38:03",
    "Time taken": "0:0:0.317"
  }
}

1 个答案:

答案 0 :(得分:1)

在solr admin中 - &gt;你的核心 - &gt; dataimport,有一个Clean选项,如果选中则会在导入之前先清理数据(对于完全导入和delta导入)。

另一个提示是,solr DIH总是使用UTC作为导入时间戳,那么你的时区是多少?首先将数据库中的datetime列转换为utc,然后再将其与dih.last_index_time进行比较。