弹性搜索总是返回“映射类型丢失” [英] Elasticsearch always returning "mapping type is missing"

查看:775
本文介绍了弹性搜索总是返回“映射类型丢失”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循这里给出的建议,以便用elasticsearch找到部分单词:

I'm following the advice given here in order to find partial words with elasticsearch:

ElasticSearch n-gram tokenfilter没有找到部分单词

创建了一个简单的bash脚本,尝试运行一个版本:

I've created a simple bash script that attempts to run a version of this:

curl -XDELETE 10.160.86.134:9200/products
curl -XPOST 10.160.86.134:9200/products -d '{
  "index": {
    "number_of_shards": 1,
    "analysis": {
       "filter": {
         "mynGram" : {"type": "nGram", "min_gram": 2, "max_gram": 10}
       },
       "analyzer": {
         "a1" : {
           "type":"custom",
           "tokenizer": "standard",
           "filter": ["lowercase", "mynGram"]
         }
       }
     }
    }
  }
}'

curl -XPUT 10.160.86.134:9200/products/_mapping -d '{
  "product" : {
    "index_analyzer" : "a1",
    "search_analyzer" : "standard",
    "properties" : {
      "product_description": {"type":"string"},
      "product_name": {"type":"string"}
    }
  }
}'

运行此脚本后,前两个命令(倾销产品,然后设置索引)似乎有助于我:

Following running this script the first two commands (dumping products, then setting the index) seem to work giving me this:

{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}

然后,在映射调用之后,我会出现以下错误:

Then it errors out following the mapping call giving me this:

{"error":"ActionRequestValidationException[Validation Failed: 1: mapping type is missing;]","status":500}

任何人都可以看到我做错了什么?搜索google启动自动完成映射未找到弹性搜索,因此似乎是一个非常常见的错误。

Can anyone see what I'm doing wrong? Searching google starts autocompleting "mapping not found elasticsearch" so it seems to be a very common error.

推荐答案

因为映射需要应用于类型:

Turns out this is happening because the mapping needs to be applied to the type:

我尝试将其应用于错误的东西:

I tried applying it to the wrong thing:

curl -XPUT 10.160.86.134:9200/products/_mapping -d '{

需要将其应用于类型:

curl -XPUT 10.160.86.134:9200/products/product/_mapping -d '{

很遗憾,一个简单的谷歌搜索无法回答这个。还有我之前发布的帖子是非常误导的,答案是错的,我也会在那里指出。

It's sad that a simple google search couldn't answer this. Also the previous post I linked to is very misleading and the answer is wrong, which I'll point out there as well.

这篇关于弹性搜索总是返回“映射类型丢失”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆