es操作记录

来源:互联网 发布:cf冰域炸服器软件 编辑:程序博客网 时间:2024/04/29 06:33

创建索引及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>"}}        ]    }'



0 0
原创粉丝点击