invalid_argument_exception在搜索中未找到字段的映射 [英] illegal_argument_exception no mapping found for field in search

查看:231
本文介绍了invalid_argument_exception在搜索中未找到字段的映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用5.1版本学习ElasticSearch.我有一个索引"mycontent"和一个类型"simpledocument".我在尝试检查simpledocument类型的建议/完成功能时遇到错误"illegal_argument_exception,未找到字段映射".详细信息如下:

I am learning ElasticSearch using the 5.1 version. I have an index "mycontent" and a type "simpledocument". I am running into an error "illegal_argument_exception no mapping found for field" while trying to check the suggest/completion feature on the simpledocument type. The details are below:

GET _search
{
  "suggest":{
    "my-suggestion":{
      "prefix":"ap",
      "completion":{
        "field":"suggest"
      }
    }
  }
}

这给了我答复:

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 5,
    "failed": 1,
    "failures": [
      {
        "shard": 0,
        "index": ".kibana",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "no mapping found for field [suggest]"
        }
      }
    ]
  },
......

映射中确实包含了建议"字段:

The mapping does have the suggest field in it:

GET _mapping/simpledocument

{
  "mycontent": {
    "mappings": {
      "simpledocument": {
        "properties": {
          "description": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "path": {
            "type": "keyword"
          },
          "suggest": {
            "type": "completion",
            "analyzer": "simple",
            "preserve_separators": true,
            "preserve_position_increments": true,
            "max_input_length": 50
          },
          "tags": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

以下是示例文档:

GET mycontent/simpledocument/7
{
  "_index": "mycontent",
  "_type": "simpledocument",
  "_id": "7",
  "_version": 1,
  "found": true,
  "_source": {
    "name": "Suggested Document",
    "description": "this document does not contain a lot of content. Mainly used to test the suggest feature.",
    "tags": [
      "suggest",
      "document"
    ],
    "suggest": [
      "and",
      "design",
      "api"
    ]
  }
}

有人可以帮我弄清楚我的错误吗?当映射存在时为什么会显示未找到映射"?

Can somebody please help me figure out my mistake? Why does it say "no mapping found" when the mapping is there?

推荐答案

GET _search将搜索所有索引,作为错误,也就是说索引.kibana没有suggest字段,因为GET _mapping/simpledocument建议字段应仅存在于simpedocument 索引类型.

GET _search will search all index, as the error, it's saying the index .kibana doesn't have the suggest field, as your GET _mapping/simpledocument, the suggest field should only exist in simpedocument index type.

所以也许您需要这样做:

so maybe you need to do it like:

GET mycontent/simpledocument/_search
{
  "suggest":{
    "my-suggestion":{
      "prefix":"ap",
      "completion":{
        "field":"suggest"
      }
    }
  }
}

这篇关于invalid_argument_exception在搜索中未找到字段的映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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