【问题标题】:How to handle multi-word/phrase synonyms in Azure Search如何在 Azure 搜索中处理多词/短语同义词
【发布时间】:2019-08-14 19:15:05
【问题描述】:

根据文章https://azure.microsoft.com/pl-pl/blog/azure-search-synonyms-public-preview/我应该在synonymMaps中使用多词/短语同义词

多词同义词

在许多全文搜索引擎中,对同义词的支持仅限于单个单词。我们的团队设计了一个解决方案,允许 Azure 搜索支持多词同义词。这允许短语查询(“”)在使用同义词时正常工作。如果有人将“热水浴缸”映射到“漩涡浴缸”,然后搜索“大热水浴缸”,Azure 搜索将返回同时包含“大热水浴缸”和“大漩涡浴缸”的匹配项。

但是,就我而言,我在子词上得到了匹配。

我的 synonymMap 看起来像:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss\n"}

我在搜索索引中有一些文档,其中包含胃肠病学(急性和慢性)等医学学科。

?search="vomiting" 之后我收到的是:

 {
            "@search.score": 1.0405536,
            "@search.highlights": {
                "disciplines/name": [
                    "<em>Acute</em> <em>and</em> <em>chronic</em> ear disease",
                    "<em>Acute</em> <em>and</em> <em>chronic</em> skin disease",
                    "<em>Gastroenterology</em> (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Haematology (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Respiratory medicine (<em>acute</em> <em>and</em> <em>chronic</em>)"
                ],

我期待:

{
    "@search.score": 1.0405536,
    "@search.highlights": {
        "disciplines/services/translatedName": [
            "<em>Gastroenterology (acute and chronic)</em>",
        ],

我做错了吗?

我试图将主要词剪切成一个单词,例如 Gastroenterology,但其中一些根本无法剪切。 提供像synonyms =&gt; "Gastroenterology (acute and chronic)" 这样的引号也不起作用。

更新

我想知道为什么我认为有问题。 好吧,我提供了:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss\n"}

实际使用:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss
     => Gastroenterology (acute and chronic)\n"}

在这种情况下,我得到 4 个结果:

"@odata.count": 4,
"value": [
        {
            "@search.score": 1.0137179,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Acute</em> <em>and</em> <em>chronic</em> ear disease",
                    "<em>Acute</em> <em>and</em> <em>chronic</em> skin disease",
                    "<em>Gastroenterology</em> (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Haematology (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Respiratory medicine (<em>acute</em> <em>and</em> <em>chronic</em>)"
                ],
                "equipment/translatedName": [
                    "Emergency <em>and</em> crictial care",
                    "In house skin <em>and</em> ear cyology"
                ],
                "disciplines/translatedName": [
                    "Anaesthesia <em>and</em> analgesia",
                    "Emergency <em>and</em> critical care"
                ]
            },
          ...
        {
            "@search.score": 0.33542877,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Chronic</em> pain management"
                ],
                "disciplines/translatedName": [
                    "Anaesthesia <em>and</em> analgesia"
                ]
            },
        ...
        {
            "@search.score": 0.13757591,
            "@search.highlights": {
                "equipment/translatedName": [
                    "Emergency <em>and</em> crictial care"
                ],
                "disciplines/translatedName": [
                    "Emergency <em>and</em> critical care"
                ]
            },
         ...
        {
            "@search.score": 0.07112321,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Chronic</em> pain management"
                ]
            },

你能解释一下在这种情况下它是如何工作的吗?

【问题讨论】:

    标签: azure-cognitive-search


    【解决方案1】:

    Azure 搜索确实支持多词同义词,并且您的案例中的结果符合预期。这里有几件事需要说明。

    首先?search="vomiting" 将返回与文档中任何位置的“呕吐”或指定同义词匹配的文档。集合 disciplines/name 中的多词同义词 Gastroenterology (acute and chronic) 匹配您的查询,从而返回文档。

    可能造成混淆的第二件事是突出显示。 Azure 搜索当前不支持短语突出显示。如果与短语查询一起使用,它会突出显示短语中的各个术语。由于匹配文档在其他地方也有单独的术语,所有这些都被突出显示。更多详情请查看Azure search highlights for phrases with double quotes。

    因此,多词同义词扩展和搜索按预期运行。您可以通过索引一个仅包含 Gastroenterology (acute and chronic) 的测试文档和另一个仅包含 acute and chronic 的测试文档来测试这一点。查询结果应该只返回第一个文档。

    如果你对高亮短语有严格的要求,你必须在检索到搜索结果后做一些客户端处理

    【讨论】:

      猜你喜欢
      • 2018-12-14
      • 2012-02-22
      • 2019-12-06
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多