更新 Azure 搜索文档架构
Update Azure search document schema
我在尝试通过代码优先方法更新 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(已死)和 Backendless(自从我上次使用它以来可能已经改变),具有基于发布的实体模式的自动实体更新,那么在 Azure 中有什么方法可以做到这一点?
我已经 found a couple articles on MSDN 关于更新索引器,但无法测试(由于封闭的开发环境......我知道,对不起)。
我特别关心的一件事是第一个 link 中的警告:
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 index operation?例如:
serviceClient.Indexes.CreateOrUpdate
我在尝试通过代码优先方法更新 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(已死)和 Backendless(自从我上次使用它以来可能已经改变),具有基于发布的实体模式的自动实体更新,那么在 Azure 中有什么方法可以做到这一点?
我已经 found a couple articles on MSDN 关于更新索引器,但无法测试(由于封闭的开发环境......我知道,对不起)。
我特别关心的一件事是第一个 link 中的警告:
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 index operation?例如:
serviceClient.Indexes.CreateOrUpdate