我已启用更改策略我的数据库
ALTER Database EMR
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)
ALTER TABLE EMR.dbo.ICDCodePCS
ENABLE CHANGE_TRACKING
WITH (TRACK_COLUMNS_UPDATED = OFF)
在天蓝色索引方面,我在下面使用 Datasource.AzureSql
DataChangePolicy = new SqlIntegratedChangeTrackingPolicy()
当我在此表中插入新行时,它似乎不会在 azure 搜索端自动更新索引。添加新行后,我几乎必须运行索引作业。我如何跟踪或调试我做错了什么?
我在 sdk 3.0.3 中使用 azure sql 和 azure search
var dataIndexer = new AzureDataIndexer()
{
DataSource = $"{EMRConsts.EMRAzureIndexNameICD10PCS}-datasource",
Description = "ICD10 Procedueral Code",
IndexName = EMRConsts.EMRAzureIndexNameICD10PCS,
Indexer = $"{EMRConsts.EMRAzureIndexNameICD10PCS}-indexer",
TableName = EMRConsts.EMRAzureIndexNameICD10PCS,
DataChangePolicy = new SqlIntegratedChangeTrackingPolicy(),
Settings = new AzureDataIndexerSettings()
{
ServiceName = _settingManager.GetSettingValue(EMRSettingNames.EmrSearchServiceName),
ApiKey = _settingManager.GetSettingValue(EMRSettingNames.EmrSearchServiceApiKeyAdmin)
},
Definition = new Index()
{
Name = EMRConsts.EMRAzureIndexNameICD10PCS,
Fields = new[]
{
new Field("ICDCodePCSId", DataType.String)
{
IsKey = true,
IsSearchable = true,
IsFilterable = true,
IsSortable = true,
IsFacetable = false,
IsRetrievable = true
},
new Field("ICDCodePCSName", DataType.String)
{
IsKey = false,
IsSearchable = true,
IsFilterable = true,
IsSortable = false,
IsFacetable = false,
IsRetrievable = true
},
new Field("ICDCodePCSShortName", DataType.String)
{
IsKey = false,
IsSearchable = true,
IsFilterable = true,
IsSortable = false,
IsFacetable = false,
IsRetrievable = true
}
},
Suggesters = new[]
{
new Suggester()
{
Name = SuggesterName,
SearchMode = SuggesterSearchMode.AnalyzingInfixMatching,
SourceFields = new List<string>() {"ICDCodePCSName", "ICDCodePCSId", "ICDCodePCSShortName" }
},
}
数据源
var dataSource =
DataSource.AzureSql(
name: dataIndexer.DataSource,
sqlConnectionString: _appConfigSqlConnection.GetConnection().ConnectionString,
tableOrViewName: dataIndexer.TableName,
changeDetectionPolicy: dataIndexer.DataChangePolicy,
description: dataIndexer.Description);
try
{
_searchClient.Indexes.Create(dataIndexer.Definition);
var indexer =
new Indexer()
{
Name = dataIndexer.Indexer,
Description = dataIndexer.Description,
DataSourceName = dataSource.Name,
TargetIndexName = dataIndexer.IndexName
};
_searchClient.Indexers.Create(indexer);
_searchClient.DataSources.Create(dataSource);
}