更新Azure搜索文档模式



我在尝试通过代码优先方法更新Azure搜索文档架构时遇到错误。

我们当前的实体具有架构:

public class SearchDocument
{
    [DataAnnotations.Key]
    public string ID;
    [IsSearchable]
    public string Title;
    [IsSearchable]
    public string Content;
}

,但我想添加一个字段,所以它变成了:

public class SearchDocument
{
    [DataAnnotations.Key]
    public string ID;
    [IsSearchable]
    public string Title;
    [IsSearchable]
    public string Content;
    [IsSortable]
    public bool Prioritize;
}

运行重新索引查询时,我会收到错误:

"The request is invalid. Details: parameters : The property 'Prioritize' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type."

哪个是有道理的...但是,如果模式匹配并更新Azure模式,是否有办法检查?我知道其他云数据库,例如Parse(Dead(和Backendless(自上次使用以来可能发生了变化(,并根据已发布的实体模式进行了自动实体更新,因此有什么方法可以在Azure中执行此操作?

我在MSDN上找到了一些有关更新索引器的文章,但无法测试(由于封闭的开发环境...我知道,对不起(。

特别关心我的一件事是第一个链接中的警告:

Important
Currently, there is limited support for index schema updates. Any schema 
updates that would require re-indexing such as changing field types are not 
currently supported.

那么这甚至可能吗?还是我必须在本地更新架构,然后登录到Azure门户并手动更新索引器模式?任何帮助都非常感谢!

Azure搜索确实支持对Azure搜索索引的增量更改。这意味着您可以添加新字段(就像您在此处使用优先级字段一样(。根据您所说的内容,看起来您正在使用.NET SDK。因此,我想知道您是否尝试过CreateOrupdate索引操作?例如:

serviceclient.indexes.createorupdate

最新更新