1. 程式人生 > 其它 >ES資料庫建立索引

ES資料庫建立索引

1. 進入Dev Tools

2. 將下列內容貼上過去,(對內容進行修改‘id’對應位置就是欄位)

PUT /kpwiki
{
  "settings": {
    "number_of_shards": "2",
    "number_of_replicas": "1"
  },
  "mappings": {
    "properties": {
        "id": {
          "type": "long"
        },
        "app_id": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "source_url": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "status": {
          "type": "long"
        },
        "create_time": {
          "type": "date"
        },
        "update_time": {
          "type": "date"
        },
        "content": {
          "type": "text",
          "analyzer": "ik_smart",
          "search_analyzer": "ik_smart"
        },
        "rich_content": {
          "type": "text",
          "analyzer": "ik_smart",
          "search_analyzer": "ik_smart"
        }
      }
    }
}