elasticSearch索引模板的基本使用

发布时间 2024-01-09 23:30:37作者: 曹伟666

创建索引模板:所有以fmmall和bar开头的索引将使用如下的模板创建索引

PUT _template/template_1?order=0
{
  "index_patterns": [ "fmmall*", "bar*" ],
  "settings": {
    "number_of_shards": 1
  },
  "order": 0,
  "mappings": {
    "properties": {
      "productId": {
        "type": "long"
      },
      "productName": {
        "type": "text"
      },
      "productsImg": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "productSku4Es": {
        "type": "nested",
        "properties": {
          "skuId": {
            "type": "long"
          },
          "skuName": {
            "type": "text"
          },
          "sellPrice": {
            "type": "float"
          }
        }
      }
    }
  }
}