更新Azure搜索文档架构 [英] Update Azure search document schema

查看:80
本文介绍了更新Azure搜索文档架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm encountering an error when trying to update an Azure search document schema through a code-first approach.

我们当前的实体具有以下模式:

Our current entity has the schema:

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

但是我想添加一个字段,使其变为:

but I want to add a field so it becomes this:

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

并且在运行重新索引查询时,出现错误:

and when running a re-indexing query, I get the error:

"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中有什么方法可以做到这一点?

Which makes sense... but is there a way check beforehand if the schema matches, and update the Azure schema? I know other cloud databases, like Parse (dead) and Backendless (may have changed since I last used it), had automatic entity updating based on the entity schema POSTed, so is there any way to do this in Azure?

我已经找到了一些文章在MSDN上有关更新索引器,但是没有'无法测试(由于封闭的开发环境,我很抱歉).

I've found a couple articles on MSDN about updating the indexers, but haven't been able to test (due to a closed dev environment... I know, I'm sorry).

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

One thing in particular that concerns me is the warning in the first 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门户并手动更新索引器架构?任何帮助,我们将不胜感激!

So is this even possible? Or do I have to update the schema locally and then log into the Azure portal and update the indexer schema manually? Any help is very appreciated!

推荐答案

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

Azure Search does support incremental changes to an Azure Search index. What this means is that you are able to add new fields (as you are doing here with your Prioritize field). Based on what you have stated, it looks like you are using the .NET SDK. For that reason, I wonder if you have tried the CreateOrUpdate index operation? For example:

serviceClient.Indexes.CreateOrUpdate

serviceClient.Indexes.CreateOrUpdate

这篇关于更新Azure搜索文档架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆