【问题标题】:Update Azure search document schema更新 Azure 搜索文档架构
【发布时间】:2018-04-24 08:02:04
【问题描述】:

我在尝试通过代码优先方法更新 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 (自从我上次使用它以来可能已经改变),具有基于 POST 的实体架构的自动实体更新,那么在 Azure 中有什么方法可以做到这一点?

我有 found a couple 文章 on 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 门户并手动更新索引器架构?非常感谢任何帮助!

【问题讨论】:

    标签: c# azure-cognitive-search


    【解决方案1】:

    Azure 搜索确实支持对 Azure 搜索索引进行增量更改。这意味着您可以添加新字段(就像您在此处使用 Prioritize 字段所做的那样)。根据您所说的,您似乎正在使用 .NET SDK。出于这个原因,我想知道您是否尝试过CreateOrUpdate index operation?例如:

    serviceClient.Indexes.CreateOrUpdate

    【讨论】:

    • 这正是我所需要的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 2019-03-31
    • 2016-07-01
    • 2017-05-12
    相关资源
    最近更新 更多