【问题标题】:Azure search index rebuild strategy using C#使用 C# 的 Azure 搜索索引重建策略
【发布时间】:2019-07-07 07:55:10
【问题描述】:

我有一个 Azure 搜索,它每 5 分钟索引一次 Azure 存储。由于存储有时也可能有删除,我正在寻找一种方法来处理这些。从文档中我了解到,除非您手动删除索引或重建索引。

完全重建可以,但我希望将停机时间降至最低。我一直在寻找这样做的策略。现在我想建立一个正在建立的第二个索引,一旦完成就删除旧的;但是感觉有点笨拙,因为我必须跟踪索引名称。

现在看起来像这样(简化):

//create new index
searchClient.Indexes.CreateOrUpdate(index);

//update indexer
var indexer = searchClient.Indexers.Get("testindexer");
indexer.TargetIndexName = index.Name;
searchClient.Indexers.CreateOrUpdate(indexer.Name);

//reset and run indexer
searchClient.Indexers.Reset(indexer.Name);
searchClient.Indexers.Run(indexer.Name);

//at this point the new index is used

//delete old index
searchClient.Indexes.Delete(oldIndex.Name);

【问题讨论】:

    标签: c# indexing azure-cognitive-search


    【解决方案1】:

    从文档看来,默认情况下为您启用了增量索引: https://docs.microsoft.com/en-us/azure/search/search-howto-indexing-azure-blob-storage

    此外,您可以使用“软删除”选项,以防那些已删除的文件可能会在某个时候重新出现。

    【讨论】:

    • 增量索引似乎只适用于新文件。 soft delete 选项在这种情况下不起作用,因为文件会立即删除并且无法重新处理。我确实想知道为什么文档要求为其设置单独的属性。已经有一个内置状态属性(在从 Azure 门户检查软删除文件的属性时),我似乎无法将其用于索引处的 soft delete 选项。
    【解决方案2】:

    documentation for recommended practices on reindexing data 类似于您提到的可能有用的场景。另外,如果你希望Azure搜索将来支持硬删除的数据删除策略,有an uservoice request that you can vote on here.正如另一个答案提到的,今天推荐的策略是使用the soft delete option that Azure Search provides,所以如果你可以重组那么你的删除是如何完成的,这也是一个潜在的选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      • 2016-09-07
      相关资源
      最近更新 更多