es操作記錄

創建索引及mapping


curl -XPUT "http://192.168.5.101:9500/productindex" -d '{
"settings" : {
        "index": {
            "analysis": {
                "analyzer": {
                    "kw": {
                        "tokenizer": "mt", 
                        "filter": [
                            "lowercase", 
                            "unique"
                        ]
                    },
                     "cn": {
                        "tokenizer": "ik", 
                        "filter": [
                            "lowercase", 
                            "unique"
                        ]
                    }
                }, 
                "tokenizer": {
                    "mt": {
                        "type": "pattern", 
                        "pattern": "`"
                    }
                }
          }
    }
 },
 "mappings" : {
     "productindex" : {
          "properties" : {
            "activities" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "area" : {
          "type" : "string",
          "analyzer" : "ik",
          "store" : "yes"
        },
        "attrIds" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "attrStrs" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "attrValues" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "c1" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "c2" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "c3" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "c4" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "canbuy" : {
          "type" : "integer",
          "store" : "yes"
        },
        "comId" : {
          "type" : "long",
          "store" : "yes"
        },
        "companyName" : {
          "type" : "multi_field",
          "fields" : {
            "index" : {
              "type" : "string",
              "analyzer" : "ik",
              "include_in_all" : false
            },
            "noindex" : {
              "type" : "string",
              "index" : "not_analyzed",
              "omit_norms" : true,
              "index_options" : "docs",
              "include_in_all" : false
            }
          }
        },
        "cost" : {
          "type" : "string",
          "index" : "no",
          "store" : "yes"
        },
        "createTime" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "evaluate" : {
          "type" : "integer",
          "store" : "yes"
        },
        "funcIds" : {
          "type" : "string"
        },
        "id" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "imgNum" : {
          "type" : "integer",
          "store" : "yes"
        },
        "imgs" : {
          "type" : "string",
          "index" : "no",
          "store" : "yes"
        },
        "intro" : {
          "type" : "string",
          "index" : "no",
          "store" : "yes"
        },
        "keyword" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "kw_search" : {
          "type" : "string",
          "analyzer" : "kw",
          "store" : "yes"
        },
        "level" : {
          "type" : "integer",
          "store" : "yes"
        },
        "mainProducts" : {
          "type" : "string",
          "analyzer" : "ik",
          "store" : "yes"
        },
        "manage" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "myscore" : {
          "type" : "integer",
          "store" : "yes"
        },
        "myscore2" : {
          "type" : "double"
        },
        "vipscore" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "oauth" : {
          "type" : "string",
          "analyzer" : "whitespace",
          "store" : "yes"
        },
        "openTime" : {
          "type" : "long"
        },
        "phone" : {
          "type" : "string"
        },
        "price" : {
          "type" : "double",
          "store" : "yes"
        },
        "refreshDay" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "refreshTime" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "sale" : {
          "type" : "integer",
          "store" : "yes"
        },
        "simgs" : {
          "type" : "string",
          "index" : "no",
          "store" : "yes"
        },
        "sort" : {
          "type" : "long"
        },
        "startNum" : {
          "type" : "integer",
          "store" : "yes"
        },
        "tags" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes"
        },
        "title" : {
          "type" : "string",
          "analyzer" : "cn",
          "store" : "yes"
        },
        "userId" : {
          "type" : "long"
        },
        "username" : {
          "type" : "string",
          "index" : "not_analyzed",
          "store" : "yes",
          "omit_norms" : true,
          "index_options" : "docs"
        },
        "vip" : {
          "type" : "integer",
          "store" : "yes"
        }
          }
      }
  }
}';

刪除索引
curl -XDELETE http://localhost:9500/productindex/productindex

設置別名

curl -XPOST 'http://localhost:9500/_aliases' -d '
    {
        "actions": [
            {"remove": {"index": "productindex-v1", "alias": "productindex"}},
            {"add": {"index":"productindex-v2", "alias": "<span style="font-family:Arial, Helvetica, sans-serif;">productindex</span>"}}
        ]
    }'



發佈了22 篇原創文章 · 獲贊 2 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章