首页 文章

“index”:弹性搜索中的“not_analyzed”

提问于
浏览
0

我删除了与cmd的映射

curl -XDELETE 'http://localhost:9200/logstash_log*/'

在我的conf中,我已将索引定义如下,

output {
   elasticsearch {
   hosts => localhost
   index => "logstash_log-%{+YYYY.MM.dd}"
 }

并尝试创建一个新的映射,但我得到了错误

#curl -XPUT http://localhost:9200/logstash_log*/_mapping/log -d '

{


     "properties":{
          "@timestamp":"type":"date","format":"strict_date_optional_time||epoch_millis"},
           "message":{"type":"string"},
           "host":{"type":"ip"},
           "name":{"type":"string","index": "not_analyzed"},
           "type":{"type":"string"}
                }

}'

{“error”:{“root_cause”:[{“type”:“index_not_found_exception”,“reason”:“no such index”,“resource.type”:“index_or_alias”,“resource.id”:“logstash_log * “,”index“:”logstash_log *“}],”type“:”index_not_found_exception“,”reason“:”no such index“,”resource.type“:”index_or_alias“,”resource.id“:”logstash_log * ”, “指数”: “logstash_log *”}, “状态”:404}

我该如何解决?任何帮助将不胜感激!!

2 回答

  • 0

    您需要像这样重新创建索引:

    # curl -XPUT http://localhost:9200/logstash_log -d '{
      "mappings": {
        "log": {
          "properties": {
            "@timestamp": {
              "type": "date",
              "format": "strict_date_optional_time||epoch_millis"
            },
            "message": {
              "type": "string"
            },
            "host": {
              "type": "ip"
            },
            "name": {
              "type": "string",
              "index": "not_analyzed"
            },
            "type": {
              "type": "string"
            }
          }
        }
      }
    }'
    

    虽然看起来你可能会更好地创建一个模板 . 将以下内容存储在 index_template.json

    {
      "template": "logstash-*",
      "mappings": {
        "log": {
          "properties": {
            "@timestamp": {
              "type": "date",
              "format": "strict_date_optional_time||epoch_millis"
            },
            "message": {
              "type": "string"
            },
            "host": {
              "type": "ip"
            },
            "name": {
              "type": "string",
              "index": "not_analyzed"
            },
            "type": {
              "type": "string"
            }
          }
        }
      }
    }
    

    然后修改您的logstash配置,如下所示:

    output {
       elasticsearch {
       hosts => localhost
       index => "logstash_log-%{+YYYY.MM.dd}"
       manage_template => true
       template_name => "logstash"
       template => "/path/to/index_template.json"
       template_overwrite => true
    }
    
  • 0

    * 是索引名称的无效字符 .

    索引名称不得包含以下字符[\,/,*,?,\“,<,>,| ,,,]

相关问题