elasticsearch:根Map定义具有不支持的参数

kdfy810k  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(512)

我正在创建一个方法来搜索泰语单词的elasticsearch和kibana。我在Map绘制方面有问题。

PUT test
{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {
    "true_name": {
      "properties": {
        "correct": { "type": "text", "analyzer": "trigrams" }
      }
    }
  }
}

像这样的错误

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters:  [true_name : {properties={correct={analyzer=trigrams, type=text}}}]"
    }
  },
  "status" : 400
}
xam8gpfp

xam8gpfp1#

不推荐使用Map类型。请参阅此文档以了解有关删除Map类型的更多信息。
在elasticsearch 6.0.0或更高版本中创建的索引只能包含一种Map类型。在5.x中创建的具有多种Map类型的索引将继续像在ElasticSearch6.x中一样工作。在ElasticSearch7.0.0的API中,类型将被弃用,而在8.0.0中,类型将被完全删除。

{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {            // note this
    "properties": {
      "correct": {
        "type": "text",
        "analyzer": "trigrams"
      }
    }
  }
}

如果您的json文档如下所示:

{
  "true_name": {
    "correct": "mapping types deprecated"
  }
}

然后索引Map将-

{
  "settings": {
    "analysis": {
      "analyzer": {
        "trigrams": {
          "tokenizer": "trigram_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "trigram_tokenizer": {
          "type": "ngram",
          "min_ngram": 3,
          "max_ngram": 3,
          "token_chars": []
        }
      }
    }
  },
  "mappings": {
    "properties": {              // note this
      "true_name": {
        "properties": {
          "correct": {
            "type": "text",
            "analyzer": "trigrams"
          }
        }
      }
    }
  }
}

相关问题