elasticsearch索引(Index)

索引操作

创建索引

PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

删除索引

DELETE /twitter

获取索引

GET /twitter
GET twitter/_settings,_mappings

索引是否存在

HEAD twitter

打开关闭索引

POST /my_index/_close
POST /my_index/_open

设置mapping(Put Mapping)

PUT twitter 
{
  "mappings": {
    "tweet": {
      "properties": {
        "message": {
          "type": "text"
        }
      }
    }
  }
}

获取mapping(Get Mapping)

GET /_mapping/tweet,kimchy
GET /_all/_mapping/tweet,book
GET /twitter,kimchy/_mapping/field/message
GET /_all/_mapping/tweet,book/field/message,user.id
GET /_all/_mapping/tw*/field/*.id

类型是否存在(Types Exists)

HEAD twitter/_mapping/tweet

更新索引设置(更新analysis需要先关闭索引)

POST /twitter/_close
PUT /twitter/_settings
{
  "analysis" : {
    "analyzer":{
      "content":{
        "type":"custom",
        "tokenizer":"whitespace"
      }
    }
  }
}
POST /twitter/_open

获取设置(Get Settings)

GET /twitter,kimchy/_settings

解析(Analyze)

GET _analyze
{
  "tokenizer" : "keyword",
  "filter" : ["lowercase"],
  "char_filter" : ["html_strip"],
  "text" : "this is a <b>test</b>"
}

解析器详解(Explain Analyze)

GET _analyze
{
  "tokenizer" : "standard",
  "filter" : ["snowball"],
  "text" : "detailed output",
  "explain" : true,
  "attributes" : ["keyword"] 
}

索引状态信息(Indices stats Segments Recovery Shard Stores)

GET /index1,index2/_stats
GET twitter/_stats?level=shards
GET /index1,index2/_segments
GET index1,index2/_recovery?human
GET index1,index2/_shard_stores?status=green

清空缓存(Clear Cache)

POST /twitter/_cache/clear
POST /kimchy,elasticsearch/_cache/clear
POST /_cache/clear

释放内存到到索引存储(Flush)

POST twitter/_flush
POST kimchy,elasticsearch/_flush
POST _flush

刷新(refresh)

POST /twitter/_refresh
POST /kimchy,elasticsearch/_refresh
POST /_refresh

强制合并(Force Merge) 可以减少分段(segment)数

POST /twitter/_forcemerge
POST /kimchy,elasticsearch/_forcemerge
POST /_forcemerge
posted @ 2017-04-01 09:12  SubjectiveInitiative  阅读(422)  评论(0编辑  收藏  举报