【问题标题】:azure search index html content天蓝色搜索索引 html 内容
【发布时间】:2017-10-31 10:19:11
【问题描述】:

我知道 blob 存储是(迄今为止)唯一支持 html 内容索引的数据源。

我的问题是,在通过 REST 将文档添加到索引之前,是否可以使用自定义分析器和 charfilter 'html_strip'(在 azure 文档中提到)去除内容?

这是我的创建索引负载:

    {
      "name": "htmlindex",  
      "fields": [
      {"name": "id", "type": "Edm.String", "key": true, "searchable": false},
      {"name": "title", "type": "Edm.String", "filterable": true, "sortable": true, "facetable": true},
      {"name": "html", "type": "Collection(Edm.String)", "analyzer": "htmlAnalyzer"}
      ],
      "analyzers": [
      {
        "name": "htmlAnalyzer",
        "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
        "charFilters": [ "html_strip" ],
        "tokenizer": "standard_v2"
      }
      ]
    }

这是我将文档添加到索引有效负载:

    {
      "value": [
        {
          "id": "1",
          "title": "title1",
          "html": [
            "<p>test1</p>",
            "<p>test2</p>"
          ]
        }
      ]
    }

现在当我搜索索引时,我看到 html 内容没有被剥离:

    {
      "@odata.context": "https://deviqfy.search.windows.net/indexes('htmlindex')/$metadata#docs",
      "value": [
          {
              "@search.score": 1,
              "id": "1",
              "title": "title1",
              "html": [
                  "<p>test1</p>",
                  "<p>test2</p>"
              ]
          }
      ]
    }

我做错了什么?如何在添加之前完成从内容中剥离 html?没有预先步骤..

【问题讨论】:

    标签: azure azure-cognitive-search


    【解决方案1】:

    因此,自定义分析器(以及相关的字符过滤器)是您可以在对文本进行标记之前执行的可选步骤。这些分析器帮助我们促进更好的全文搜索。

    在使用 REST API 将文档推送到索引时,Azure 搜索没有修改要索引的文档内容的机制。您必须自己执行此操作,因为分析器用​​于从存储在搜索索引中的文档中提取术语。

    如果您有兴趣了解更多详情:https://docs.microsoft.com/en-us/azure/search/search-lucene-query-architecture

    【讨论】:

    • 添加要索引的带有 html 文件的 blob 存储容器的数据源能够将内容与标记分开。这是如何实现的?如果不可能。
    • 当您尝试从 blob 中索引数据时,我们可以运行某些内容提取工具来去除 HTML,或从办公文件、PDF 等中读取文本。这是非破坏性意义上的“预处理”步骤,因为您的实际 blob 没有被修改。当您使用 REST API 将数据推送到索引时,我们不会修改实际文档,因为没有“原始”文档的概念。话虽如此,您能否详细说明为什么使用 Blob 存储不适合您?也许如果我更了解您的情况,我可以尝试寻找替代方案?
    猜你喜欢
    • 1970-01-01
    • 2017-12-15
    • 2020-03-02
    • 1970-01-01
    • 2021-02-12
    • 2017-09-14
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    相关资源
    最近更新 更多