es 常見操作

1.創建模板

PUT _template/template_purchaser_info
{

    "order": 1,
    "template": "purchaser_invoice_*",
    "settings": {
      "index": {
        "number_of_shards": "6",
        "number_of_replicas": "0",
        "mapper": {
          "dynamic": "false"
        }
      }
    },
    "mappings": {
      "invoice": {
        "properties": {
          "id": {
            "type": "text"
          },
          "invoiceType": {
            "type": "keyword"
          },
          "invoiceNo": {
            "type": "keyword"
          },
          "invoiceCode": {
            "type": "keyword"
          },
          "status": {
            "type": "keyword"
          },
          "createTime": {
            "type": "date",
            "format": "date_time"
          },
          "updateTime": {
            "type": "date",
            "format": "date_time"
          },
          "createUserId": {
            "type": "keyword"
          },
          "createUserName": {
            "type": "keyword"
          }

        }
      }
    },
    "aliases": {
      "purchaser_invoice_info": {}
    }
  
}

2.基於模板建索引

匹配到映射路徑即可

PUT purchaser_invoice_v1

3 給索引添加字段


POST purchaser_invoice_info/_mapping/invoice
{
    "properties": {
        "customerNo": {
            "type": "keyword"
        },
        "auditStatus": {
            "type": "keyword"
        }
    }
}

4.查看索引mapping

GET  purchaser_invoice_info/_mapping

5.dsl查詢


GET tax_goods/_search
{
  "query": {
    "match": {
      "taxcodeName": "垃圾清運費"
    }
  }
}

6.條件刪除doc

POST tax_goods/_delete_by_query
{
  "query": {
    "match": {
      "goodsName": "垃圾清運費"
    }

7.刪除索引

DELETE purchaser_invoice_v1
  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章