【问题标题】:Recreation of mapping elastic search映射弹性搜索的再创造
【发布时间】:2016-06-20 16:14:29
【问题描述】:

logstash config我已经在elasticsearch和kibana上创建了我的索引并上传了数据。现在我想更改索引的映射并将一些字段更改为不分析。下面是我想从现有映射中替换的映射。但是当我在命令下运行时,它给了我错误

{"error":{"root_cause":[{"type":"index_already_exists_exception","re​​ason":"已经 存在","index":"rettrmt"}],"type":"index_already_exists_exception","re​​ason":"已经 存在","index":"rettrmt"},"status":400}

请帮助将其关闭。

curl -XPUT 'http://10.56.139.61:9200/rettrmt' -d '{
  "rettrmt": {
    "aliases": {},
    "mappings": {
      "RETTRMT": {
        "properties": {
          "@timestamp": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "@version": {
            "type": "string"
          },
          "acid": {
            "type": "string"
          },
          "actor_id": {
            "type": "string",
            "index": "not_analyzed"
          },
          "actor_type": {
            "type": "string",
            "index": "not_analyzed"
          },
          "channel_id": {
            "type": "string",
            "index": "not_analyzed"
          },
          "circle": {
            "type": "string",
            "index": "not_analyzed"
          },
          "cr_dr_indicator": {
            "type": "string",
            "index": "not_analyzed"
          },
          "host": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "orig_input_amt": {
            "type": "double"
          },
          "path": {
            "type": "string"
          },
          "r_cre_id": {
            "type": "string"
          },
          "sub_use_case": {
            "type": "string",
            "index": "not_analyzed"
          },
          "tran_amt": {
            "type": "double"
          },
          "tran_id": {
            "type": "string"
          },
          "tran_particulars": {
            "type": "string"
          },
          "tran_particulars_2": {
            "type": "string"
          },
          "tran_remarks": {
            "type": "string"
          },
          "tran_sub_type": {
            "type": "string"
          },
          "tran_timestamp": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "tran_type": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "use_case": {
            "type": "string",
            "index": "not_analyzed"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1457331693603",
        "uuid": "2bR0yOQtSqqVUb8lVE2dUA",
        "number_of_replicas": "1",
        "number_of_shards": "5",
        "version": {
          "created": "2000099"
        }
      }
    },
    "warmers": {}
  }
}'

【问题讨论】:

    标签: elasticsearch logstash kibana bigdata


    【解决方案1】:

    您首先需要删除索引,然后使用正确的映射重新创建它。在这里,您会收到错误 index_already_exists_exception,因为您尝试在旧索引仍然存在时创建索引,因此发生了冲突。

    先运行这个:

    curl -XDELETE 'http://10.56.139.61:9200/rettrmt'
    

    然后你可以再次运行你的命令。请注意,这会删除您的数据,因此您必须重新填充索引。

    【讨论】:

    • 如果我删除索引,它也会删除数据不是吗?
    • 但是我已经删除了索引,所以它也删除了数据,然后再次运行我的命令来更改映射。它只是放置了我需要的映射,但是当我再次上传数据然后通过 kibana 再次看到已分析的字段,我在映射中未分析该字段。猜猜我做错了什么。
    • 是的,但如果您想更改映射,您实际上别无选择。
    • 你能分享一个你正在索引的文档以及你认为不应该分析的字段吗?
    • 您有 gmail 邮箱,以便我们快速聊天讨论吗?这真的很有帮助。
    【解决方案2】:

    你尝试过类似的方法吗?

    curl -XPUT 'http://10.56.139.61:9200/rettrmt/_mapping/RETTRMT' -d '
    {
      "properties": {
        "actor_id": { // or whichever properties you want to add
                "type": "string",
                "index": "not_analyzed"
        }
      }
    }
    

    为我工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      相关资源
      最近更新 更多