新建mapping出错resource_already_exists_exception

来源:14-9 elasticsearch的简单查询 - 1

lihsing

2018-12-11

请问这个错误是什么原因?

操作过程


// 第一步,删除lagou索引
DELETE /lagou

// 第二步,新建lagou索引
PUT /lagou
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1
  }
}

// 第三步,创建mapping
PUT /lagou
{
  "mappings": {
    "job": {
      "properties": {
        "title": {
          "store": true,
          "type": "text",
          "analyzer": "ik_max_word"
        },
        "company_name": {
          "type": "keyword"
        },
        "desc": {
          "type": "text"
        },
        "comments": {
          "type": "integer"
        },
        "add_time": {
          "type": "date",
          "format": "yyyy-MM-dd"
        }
      }
    }
  }
}

第三步输出结果

{
  "error": {
    "root_cause": [
      {
        "type": "resource_already_exists_exception",
        "reason": "index [lagou/9aV1d0lwQ7iysahTj_oX2w] already exists",
        "index_uuid": "9aV1d0lwQ7iysahTj_oX2w",
        "index": "lagou"
      }
    ],
    "type": "resource_already_exists_exception",
    "reason": "index [lagou/9aV1d0lwQ7iysahTj_oX2w] already exists",
    "index_uuid": "9aV1d0lwQ7iysahTj_oX2w",
    "index": "lagou"
  },
  "status": 400
}

请问是什么原因呢?

写回答

1回答

bobby

2018-12-12

报错是说index已经存在 可以先删除 然后尝试 https://stackoverflow.com/questions/35838208/recreation-of-mapping-elastic-search 看看这个问答

0
0

Scrapy打造搜索引擎 畅销4年的Python分布式爬虫课

带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎

5796 学习 · 6290 问题

查看课程