其他分享
首页 > 其他分享> > ES的基本操作

ES的基本操作

作者:互联网

1. 创建索引

说明:在这里面的mappings部分,可以从其他索引中进行拷贝过来,注意这个mappings中的info是自定义的,有的用_docs

PUT /test12
{
    "mappings" : {
      "info" : {
        "properties" : {
          "@timestamp" : {
            "type" : "date"
          },
          "@version" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "addtime" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss||yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
          },
          "equ_id" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "path" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "pid" : {
            "type" : "long"
          }
        }
      }
    }
}

2. 向索引中新增记录

说明:这里的info就是在创建索引中mappings下的那个属性值,如果那里是_docs,那这里就是_docs

POST /test12/info
{
    "equ_id" : "34020000001320000892",
    "path" : "https://pic-grd.obs.cn-south-1.myhuaweicloud.com:443/picture/20220627/34020000001320000892/192.168.1.64_01_20220627102232964_TIMING.jpg",
    "addtime" : "2022-06-27 10:22:32",
    "pid" : "18165922430487424"
}

3. 删除索引

DELETE /test12

标签:info,mappings,keyword,text,索引,基本操作,type,ES
来源: https://www.cnblogs.com/TheoryDance/p/16422018.html