【问题标题】:understand azure search charFilters mapping了解 azure search charFilters 映射
【发布时间】:2016-08-03 14:00:58
【问题描述】:

我使用以下自定义分析器创建索引

"analyzers":[
 {
    "name":"shinglewhite_analyzer",
    "@odata.type":"#Microsoft.Azure.Search.CustomAnalyzer",
    "charFilters":[
       "map_dash"
    ],
    "tokenizer":"whitespace",
    "tokenFilters":[
        "shingle"
    ]
 }
],
"charFilters":[
 {
    "name":"map_dash",
     "@odata.type":"#Microsoft.Azure.Search.MappingCharFilter",
     "mappings":[ "_=> " ]
 }
]

问题是输入中的 ice_cream 之类的词不会匹配查询冰淇淋,但它会匹配 icecream。有人可以帮助我了解这是如何工作的吗?如果我做错了什么?

此外,我们希望查询“ice cream”以匹配“ice cream”、“icecream”和“ice and cream”,但优先排序。

【问题讨论】:

    标签: tokenize analyzer azure-cognitive-search


    【解决方案1】:

    为了映射到空间,请使用以下符号(我们将更新文档以包含此信息):

    {
        "name":"map_dash",
        "@odata.type":"#Microsoft.Azure.Search.MappingCharFilter",
        "mappings":[ "_=>\\u0020" ]
    }         
    

    此外,默认情况下,shingle 标记过滤器用空格分隔标记。如果您想在没有分隔符的情况下将后续标记合并为一个,则需要自定义过滤器,如下例所示:

    {
        "name": "my_shingle",
        "@odata.type":"#Microsoft.Azure.Search.ShingleTokenFilter",
        "tokenSeparator": "" 
    }
    

    通过对标记 ice_cream 的这两个更改,您的分析器将生成:ice、icecream、cream。

    希望对你有帮助

    【讨论】:

    猜你喜欢
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    • 2014-06-04
    • 2014-09-16
    • 2013-08-15
    相关资源
    最近更新 更多