1. 程式人生 > >ELK系列三:Elasticsearch的簡單使用和配置文件簡介

ELK系列三:Elasticsearch的簡單使用和配置文件簡介

stat 創建索引 prop creat .com 索引 mapping 圖片 keyword

1、定義模板創建索引:



首先定義好一個模板的例子

{
  "order":14,
  "template":"ids-1",
  "state":"open",
  "settings":{
    "number_of_shards":1
  },
  "mappings":{
    "warnning":{
      "properties":{
        "name":{
          "type":"keyword"
        },
        "createtime":{
            "type":"date",
            "format":"strict_date_optional_time||epoch_millis"
        },
        "category":{
          "type":"keyword"
        },
        "srcip":{
          "type":"keyword"
        },
        "dstip":{
          "type":"keyword"
        }
      }
    }
  }
}

然後使用PUT方法,發送給Elasticsearch。可以使用下圖插件:
技術分享圖片
然後查看一下,模板是否上傳成功:
技術分享圖片

#1、新版本的elasticsearch中,模板的index只能有true何false兩個選擇,與是否分詞無關;不分詞請把類型(type)設置成keyword。
#2、新版本中不在保留string類型,取而代之的是text類型和keyword類型,text類型可分詞,keyword類型不分詞。

2、創建索引操作:



技術分享圖片

技術分享圖片

ELK系列三:Elasticsearch的簡單使用和配置文件簡介