Azure 在API版本2016-09-01中创建自定义分析器时出错
我目前正在Azure搜索中使用自定义分析器。我之前在Azure搜索API“2015-02-28-preview”的预览版上取得了很多成功,该版本引入了该功能。我目前正在尝试将我的自定义分析器迁移到API版本“2016-09-01”,根据本文()所述,该版本包括自定义分析器支持。我的分析仪配置如下:Azure 在API版本2016-09-01中创建自定义分析器时出错,azure,azure-cognitive-search,Azure,Azure Cognitive Search,我目前正在Azure搜索中使用自定义分析器。我之前在Azure搜索API“2015-02-28-preview”的预览版上取得了很多成功,该版本引入了该功能。我目前正在尝试将我的自定义分析器迁移到API版本“2016-09-01”,根据本文()所述,该版本包括自定义分析器支持。我的分析仪配置如下: "analyzers": [ { "name": "phonetic_area_analyzer", "@odata.type": "#Microsoft.Azure
"analyzers": [
{
"name": "phonetic_area_analyzer",
"@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer": "area_standard",
"tokenFilters": [ "lowercase", "asciifolding", "areas_phonetc" ]
},
{
"name": "partial_area_analyzer",
"@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer": "area_standard",
"tokenFilters": [ "lowercase", "area_token_edge" ]
},
{
"name": "startsWith_area_analyzer",
"@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer": "area_keyword",
"tokenFilters": [ "lowercase", "asciifolding", "area_edge" ]
}
],
"charFilters": [],
"tokenizers": [
{
"name":"area_standard",
"@odata.type":"#Microsoft.Azure.Search.StandardTokenizer"
},
{
"name":"area_keyword",
"@odata.type":"#Microsoft.Azure.Search.KeywordTokenizer"
}
],
"tokenFilters": [
{
"name": "area_edge",
"@odata.type": "#Microsoft.Azure.Search.EdgeNGramTokenFilter",
"minGram": 2,
"maxGram": 50
},
{
"name": "area_token_edge",
"@odata.type": "#Microsoft.Azure.Search.EdgeNGramTokenFilter",
"minGram": 2,
"maxGram": 20
},
{
"name": "areas_phonetc",
"@odata.type": "#Microsoft.Azure.Search.PhoneticTokenFilter",
"encoder": "doubleMetaphone"
}
]
此配置在使用版本“2015-02-28-Preview”时有效,但当我尝试版本“2016-09-01”时,我得到以下错误作为响应:
{
"error": {
"code": "",
"message": "The request is invalid. Details: index : The tokenizer of type 'standard' is not supported in the API version '2016-09-01'.\r\n"
}
}
我的配置是否存在问题,或者版本“2016-09-01”是否只允许有限的自定义分析器功能子集?如果是这种情况,请有人告诉我一些文档的方向,详细说明支持哪些功能?很抱歉,更新文档的过程中出现了延迟。这是我的拉取请求,具有我们在2016-09-01引入的更改:(此处请求访问) 在您的示例中,将KeywordTokenizer更改为KeywordTokenizerV2,对于StandardTokenizer和EdgeNGramTokenFilter也是如此 更新:
新版本的文档已在线发布:啊,太好了,非常感谢。这似乎很有效。我担心功能一直停留在预览阶段。顺便问一下,我想知道在.NET SDK中是否支持自定义分析器,还是我们需要使用REST API?根据这篇博文:,我相信最新版本的.NET SDK.Hmm中支持自定义分析器。。我刚刚查看了.NETSDK的最新版本3.0.1,自定义分析器的实现似乎不完整。我正在尝试使用SearchServiceClient.Indexes.CreateOrUpdateAsync()创建索引,它采用定义索引配置的Microsoft.Azure.Search.Models.Index。索引类型包含Analyzer、TokenFilter和Tokenizer的字段,这些字段都是在Microsoft.Azure.Search.Models中定义的类型,但这些类型中的每一个都只有一个“Name”属性,没有定义各自设置的属性。我遗漏了什么吗?糟糕的是,我看到每个Analyzer和Tokenizer类型都有模型,只是我使用Newtonsoft.Json将我的索引配置解析为.NET模型,例如JsonConvert.DeserializeObject(System.IO.File.ReadAllText(“myjsonconfig.Json”);并且没有解析正确的分析器/标记器类型。有没有更好的方法可以将配置作为json解析到.NET配置对象中,而无需手动解析json?您介意为最后一个问题创建一个新的SO帖子吗?