azure search index/indexer 未索引新数据

azure search index/indexer not indexing new data

短篇小说: 我正在使用 azure 搜索服务,看起来它没有为添加到我的视图中的新行编制索引(数据源指向一个视图)。

长话短说: 我有一个视图,它是从我数据库中的许多表创建的。我创建了一个指向此视图的数据源。该视图有很多列,这里相关的是 2:Id 和 ChangeIndicator。更改指示器 (int) 有一个计算值,是对用于构建视图的表中更改的一些值求和的结果。 我定义了一个索引,映射到我的数据源和一个索引器。索引器正确填充索引(第一次),它看到我视图中的所有行并正确索引数据(据我检查)。

问题是当我在视图中添加新行时 - 这些行未编入索引。

我使用 API 调用创建数据源、索引和索引器。

数据源是这样创建的:

{
    "name": "cs5datasource",
    "description": "Data source for cs search",
    "type": "azuresql",
    "credentials": { "connectionString" : "XXX - Connection string - XXX" },
    "container": {"name": "UserDataAggregatedView"},
    "dataChangeDetectionPolicy": {
        "@odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",  
        "highWaterMarkColumnName" : "ChangeIndicator" 
    }
}

索引是这样创建的:

{
    "name": "cs5indexer",
    "description": "Indexer service",
    "dataSourceName": "cs5datasource",
    "targetIndexName": "cs5index",
    "schedule": {"interval" : "PT5M", "startTime" : "2017-06-24T22:00:00Z"}
}

添加新行(未编入索引的行)后,如果我删除索引器并重新创建它,视图会正确编入索引。问题似乎是检测新行。添加的新行是有效的,索引过程中不会产生错误。

我需要一种方法将新添加的行索引到我的视图,以及一种从索引中删除已删除行的方法。如何做到这一点?

谢谢。

稍后编辑: 新添加的行未编入索引。 我添加的新行如下所示:

Id |   name   | lang  |    proffesion   | changeIndicator
26 | test_011 |  en   | history teacher |    49536867 

您视图中的 changeIndicator 列可能不适合作为高水印列。对于每个新的或更新的行,高水位线列应该单调增加;我们建议使用 rowversion 列进行更改跟踪。

来自Capturing new, changed, and deleted rows

This policy can be used if your table or view contains a column that meets the following criteria:

  • All inserts specify a value for the column.
  • All updates to an item also change the value of the column.
  • The value of this column increases with each insert or update.
  • Queries with the following WHERE and ORDER BY clauses can be executed efficiently: WHERE [High Water Mark Column] > [Current High Water Mark Value] ORDER BY [High Water Mark Column].

要捕获已删除的行,请阅读 Connecting Azure SQL Database to Azure Search using indexers 中的 Soft Delete Column Deletion Detection policy 部分。