ES相关API备忘(一)

来源:互联网 发布:网络黑名单 编辑:程序博客网 时间:2024/06/07 09:25

查看所有节点: http://localhost:9200/_cat/nodes?v

查看当前索引数据: http://localhost:9200/myindex/_search?pretty -d

当前mapping: http://localhost:9200/myindex/_mapping

测试分词:http://localhost:9200/myindex/_analyze?pretty&analyzer=ik_smart&text=com.test.123中文 abc ddd        (ik_max_word    ik_smart)

删除索引: curl -XDELETE'http://localhost:9200/myindex

创建索引:curl -XPUT http://10.20.26.119:9200/pafa5log  -d '
 {
   "settings": {
     "analysis": {
       "analyzer": {
         "optimizeIK": {
           "type": "custom",
           "tokenizer": "ik_max_word",
           "filter": [
             "stemmer"
           ]
         }
       }
     }
   }}'

直接在linux命令下执行。或存成文件 执行

创建表结构:

curl -XPOST http://localhost:9200/myindex/loginfo/_mapping -d'{ 
    "loginfo": {
             "_all": {
           "analyzer": "optimizeIK",
           "search_analyzer": "optimizeIK",
           "term_vector": "no", "store": "false"
        },
        "_ttl" : { 
        "enabled" : true, "default" : "3d" 
        },
        "properties": {
        "contextStack":{
        "type": "string", "store": "no",
                "analyzer": "ik_smart", "search_analyzer": "ik_smart",
                "include_in_all": "true"        
        },
          "appName": {
                "type": "string", "store": "no",
                "index": "not_analyzed",
                "include_in_all": "false" 
            },
            "instanceIp": {
                "type": "string",  "store": "no",
               "index": "not_analyzed",
                "include_in_all": "false" 
            },
            "loggerName": {
                "type": "string", "store": "no",
                "analyzer": "optimizeIK",  "search_analyzer": "optimizeIK",
                "include_in_all": "true" 
            },
            "millis": {
                "type": "string",  "store": "no",
                index: "not_analyzed",
                "include_in_all": "true" 
            },
            "level": {
                "type": "string",  "store": "no",
                "index": "not_analyzed",
                "include_in_all": "false" 
            },
            "message": {
                "type": "string",  "store": "no",
                "analyzer": "ik_smart", "search_analyzer": "ik_smart",
                "include_in_all": "true" 
            },
            "thrown":  {
             "type": "string",  "store": "no",
              "index": "not_analyzed",
               "include_in_all": "true" 
           }
            }
        }
    }
}'

0 0
原创粉丝点击