在与 Azure 搜索中的标准分析器不同的分析器中使用通配符

Use wildcard with different analyzer than the standard one in Azure Search

我需要允许文本自由搜索包含破折号的值,例如 ABCD-12EF

我知道 standard 分析器不能很好地与 - 一起使用,因为它将内容拆分为多个标记。我已经创建了一个如下所示的索引来试用 keywordwhitespace 分析器,但似乎 * 字符不再起作用。只有当我搜索没有 * 所以 ABCD-12EF 的完整值时,我才会得到结果。如果我搜索 ABCD-12EFABCD-12*ABCD*,我不会得到任何结果。

知道为什么吗?

public class IndexTryOut
{
    [Key, IsFilterable]
    public string Id { get; set; }

    [IsSearchable, IsFilterable]
    [Analyzer("keyword")]
    public string Data1 { get; set; }

    [IsSearchable, IsFilterable]
    [Analyzer("whitespace")]
    public string Data2 { get; set; }
}

您可以定义一个自定义分析器,它使用“关键字”分词器和“小写”分词过滤器 - 请参阅我对这个问题的回答: