illegal_argument_exception:没有为字段find映射

我正在尝试关注如何使用弹性search( version 12.1.0 )作为search引擎的一些教程。 而现在,我试图运行这几行:

 function initMapping() { return elasticClient.indices.putMapping({ index: indexName, type: "document", body: { properties: { title: { type: "string" }, content: { type: "string" }, suggest: { type: "completion", analyzer: "simple", search_analyzer: "simple", payloads: true } } } }); } function addDocument(document) { return elasticClient.index({ index: indexName, type: "document", body: { title: document.title, content: document.content, suggest: { input: document.title.split(" "), output: document.title, payload: document.metadata || {} } } }); } function getSuggestions(input) { return elasticClient.suggest({ index: indexName, body: { docsuggest: { text: input, completion: { field: "suggest", fuzzy: true } } } }) } 

但是,当我点击相关的url,我得到这几行输出:

 { [Error: [illegal_argument_exception] no mapping found for field [suggest]] status: 400, displayName: 'BadRequest', message: '[illegal_argument_exception] no mapping found for field [suggest]', path: '/docs-engine/_suggest', query: {}, body: { error: { root_cause: [Object], type: 'search_phase_execution_exception', reason: 'all shards failed', phase: 'query', grouped: true, failed_shards: [Object], caused_by: [Object] }, status: 400 }, statusCode: 400, response: '{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"no mapping found for field [suggest]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"docs-engine","node":"gxmLpCqdSISUvPh6fn56CQ","reason":{"type":"illegal_argument_exception","reason":"no mapping found for field [suggest]"}}],"caused_by":{"type":"illegal_argument_exception","reason":"no mapping found for field [suggest]"}},"status":400}', toString: [Function], toJSON: [Function] } 

所以,错误说弹性search无法弄清楚该领域的suggest 。 我试图映射其他属性,但它是不可能的。 我总是得到与相应的属性相同的错误。

有什么好主意吗?