Azure 搜索条件技能用大于等于运算符比较两个字段

Azure Search Conditional Skill Compare Two Fields With Greater Than Equal To Operator

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

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

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

错误信息

我的技能组定义如下,但每当我执行索引器时,我都会得到 left Parameter name: left operand is not a number 的错误详细信息。但是,当我切换到相等运算符 == 时,它起作用了!无论 field1 或 field2 是 cosmos db 中的字符串或数字,还是搜索索引中的 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"
      }
}

感谢您的指导!

不可以,只能比较字符串是否相等。目前唯一的解决方法是使用 Custom Web API to do the comparison externally. You can suggest adding string comparisons for the ConditionalSkill on UserVoice.