首页 > 解决方案 > 使用 Azure 认知搜索为静态 HTML blob 存储内容编制索引未按预期工作

问题描述

我正在对 blob 存储中的静态 HTML 内容进行索引。该文档指出,在从该数据源索引内容时,预处理分析器将去除周围的 HTML 标记。但是,我们的content值始终是整个原始 HTML 文档。我也无法提取我们的“元描述”标签的价值。根据Indexing Blob Storage 上的文档metadata_description,HTML 内容应自动生成一个属性,但该值始终为 null。

我尝试了许多不同的索引器配置,但到目前为止还无法判断我是否有错误配置,或者 Azure 搜索是否无法正确识别内容类型。

Blob 存储中的所有文件都有一个.html文件扩展名,并且内容类型列显示text/html.

这是索引器配置(一些位 <redacted>):

{
  "@odata.context": "https://<instance>.search.windows.net/$metadata#indexers/$entity",
  "@odata.etag": "\"<tag>\"",
  "name": "<name>",
  "description": null,
  "dataSourceName": "<datasource name>",
  "skillsetName": null,
  "targetIndexName": "<target index>",
  "disabled": null,
  "schedule": {
    "interval": "PT2H",
    "startTime": "0001-01-01T00:00:00Z"
  },
  "parameters": {
    "batchSize": null,
    "maxFailedItems": -1,
    "maxFailedItemsPerBatch": null,
    "base64EncodeKeys": null,
    "configuration": {
      "parsingMode": "text",
      "dataToExtract": "contentAndMetadata",
      "excludedFileNameExtensions": ".png .jpg .mpg .pdf",
      "indexedFileNameExtensions": ".html"
    }
  },
  "fieldMappings": [
    {
      "sourceFieldName": "metadata_storage_path",
      "targetFieldName": "id",
      "mappingFunction": {
        "name": "base64Encode",
        "parameters": null
      }
    },
    {
      "sourceFieldName": "metadata_description",
      "targetFieldName": "description",
      "mappingFunction": null
    },
    {
      "sourceFieldName": "metadata_storage_path",
      "targetFieldName": "url",
      "mappingFunction": {
        "name": "extractTokenAtPosition",
        "parameters": {
          "delimiter": "<delimiter>",
          "position": 1
        }
      }
    }
  ],
  "outputFieldMappings": [],
  "cache": null
}

标签: azuresearchmetaazure-cognitive-search

解决方案


这可能是由于您的索引器中的配置 "parsingMode": "text"

此解析模式用于从文档中提取文字文本值。在这种情况下,这包括所有的 html 标记。

将该配置更改为 "parsingMode": "default" 以从文档中删除 html 标记。


推荐阅读