Azure搜索条件技能将两个大于等于运算符的字段进行比较



问题:Azure Cognitive Search的ConditionalSkill可以使用大于或等于运算符来比较两个字符串字段吗?还是只能在数字字段之间进行不相等的比较?

我希望使用条件技能来比较来自Cosmos DB的两个字段。字段1和字段2。两者都是字符串字段(或者至少comsosdb数据源似乎强制它成为索引器中的字符串(。我的目标是在我的搜索索引中创建一个名为compareResults的新字段,它是一个布尔值。如果字段1('ABC'(大于或等于字段2('DEF'(,则应返回true,否则返回false。

文档页面上提供的示例似乎只显示了两个字段之间的字符串相等,以及数字字段和文字值的大于或等于比较。

错误消息

我的技能集定义如下,但每当我执行索引器时,我都会得到left Parameter name: left operand is not a number的错误详细信息。然而,当我切换到相等运算符==时,它就起作用了!无论field1或field2是cosmos数据库中的字符串或数字,还是搜索索引中的Edm.string或Edm.Int32,都会发生这种情况。

技能集定义

{
"description": "Compare Fields",
"name":"mycustomskill",
"skills": [
{
"@odata.type": "#Microsoft.Skills.Util.ConditionalSkill",
"context": "/document",
"inputs": [
{
"name": "condition",
"source": "= $(/document/field1) >= $(/document/field2)"
},
{
"name": "whenTrue",
"source": "= true"
},
{
"name": "whenFalse",
"source": "= false"
}
],
"outputs": [
{
"name": "output",
"targetName": "compareResults"
}
]
}
],
"cognitiveServices": {
"@odata.type": "#Microsoft.Azure.Search.CognitiveServicesByKey",
"description": "/subscriptions/x/resourceGroups/y/providers/Microsoft.CognitiveServices/accounts/z",
"key": "abc123"
}
}

感谢您的指导!

否,只能比较字符串是否相等。目前唯一的解决方案是使用自定义Web API从外部进行比较。您可以建议在UserVoice上为ConditionalSkill添加字符串比较。

最新更新