ES操作

2019-03-25  本文已影响0人  Jlan
  1. 查询有哪些索引
curl -XGET 127.0.0.1:9200/_cat/indices  # 在终端
GET /_cat/indices  # 在kibana
  1. 创建索引
PUT /aaa/     # 创建索引,settings可选
{
  "settings": {
    "analysis": {
      "analyzer": {
        "charsplit": {
          "char_filter": [
            "html_strip"
          ],
          "filter": [
            "lowercase",
            "asciifolding"
          ],
          "tokenizer": "charsplit"
        }
      },
      "tokenizer": {
        "charsplit": {
          "min_gram": "1",
          "type": "ngram",
          "max_gram": "1",
          "token_chars": [
            "letter",
            "digit"
          ]
        }
      }
    }
  }
}


POST /aaa/aaa_doc/_mapping  # 创建doc
{
    "aaa_doc":{
        "dynamic":"false",
        "properties":{
            "classID":{
                "type":"integer"
            },
            "lastModifiedTime":{
                "format":"yyyy-MM-dd HH:mm:ss",
                "type":"date"
            },
            "answer":{
                "type":"keyword"
            },
            "question":{
                "analyzer":"charsplit",
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                }
            },
            "id":{
                "type":"keyword"
            },
            "similarID":{
                "type":"keyword"
            },
            "similarCount":{
                "type":"integer"
            }
        }
    }
}
  1. 关闭和打开索引
    在处理elasticsearch的时候,通常需要不断地调整索引的配置,以期达到期望的效果。需要先关闭索引,设置好之后,然后再打开才能生效。
POST /aaa/_close  

PUT /aaa/_settings?preserve_existing=true
{"max_result_window":"2000000000"}

POST /aaa/_open  
上一篇 下一篇

猜你喜欢

热点阅读