【问题标题】:adding analyser in ElasticSearch field of type array在数组类型的 ElasticSearch 字段中添加分析器
【发布时间】:2020-11-17 23:15:07
【问题描述】:

我有一个弹性搜索对象,其中一个字段是数组类型。现在我想应用与标准默认分析器不同的分析器。当我在索引定义中传递分析器时,它会抛出错误。我该怎么做?

在下面的示例中,技能包含一个值数组。我想要的只是应用不同的分析器并查看结果。我怎样才能做到这一点?

      "skills": {
        "type": "object",
        "analyzer": "simple"
      },
      "profile": {
        "type": "text",
        "analyzer": "simple"
      },
      "job_title": {
        "type": "text",
        "analyzer": "simple"
      },

出现以下错误:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]"
    }
  },
  "status": 400
}

【问题讨论】:

  • 这将有助于查看您遇到的错误以及您正在运行的不同命令
  • 更新了有问题的错误信息
  • 您只能为text 字段定义和分析器,而不能为object 字段定义和分析器
  • 我该如何解决这个问题?
  • 你能展示一个你想搜索的示例文档吗?

标签: elasticsearch eclipse-memory-analyzer elasticsearch-analyzers


【解决方案1】:

ES中有no dedicatedarray数据类型。如果skills是关键字数组,可以使用type:text & analyzer:simple

提示:如果您想快速迭代不同分析器的效果,可以使用_analyze 端点,而无需每次都删除/调整/重新索引:

GET _analyze
{
  "text": [
    "lorem",
    "ipsum",
    "123abc"
  ],
  "analyzer": "simple"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 2020-05-13
    • 1970-01-01
    相关资源
    最近更新 更多