【问题标题】:illegal_argument_exception no mapping found for field in search非法参数异常没有为搜索中的字段找到映射
【发布时间】:2017-09-29 09:44:44
【问题描述】:

我正在使用 5.1 版本学习 ElasticSearch。我有一个索引“mycontent”和一个类型“simpledocument”。我在尝试检查 simpledocument 类型的建议/完成功能时遇到错误“illegal_argument_exception no mapping found for field”。详情如下:

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]"
        }
      }
    ]
  },
......

映射中确实有建议字段:

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"
    ]
  }
}

有人可以帮我找出我的错误吗?为什么有映射时提示“找不到映射”?

【问题讨论】:

    标签: elasticsearch mapping


    【解决方案1】:

    GET _search 将搜索所有索引,作为错误,表示索引.kibana 没有suggest 字段,作为您的@987654324 @,建议字段应该只存在于simpedocument索引类型中。

    所以也许你需要这样做:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-07
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多