首页  

elasticsearch5.0索引设置     所属分类 elasticsearch 浏览量 1176
根据原文翻译整理
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/indices-update-settings.html


The REST endpoint is /_settings (to update all indices) 
or {index}/_settings to update one (or more) indices settings.

修改所有索引或指定索引的设置


curl -XPUT 'localhost:9200/my_index/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 4
    }
}'


批量更新禁用刷新
curl -XPUT localhost:9200/test/_settings -d '{
    "index" : {
        "refresh_interval" : "-1"
    } }'
    
"refresh_interval" : "1s"  默认一秒钟刷新一次

a force merge should be called
curl -XPOST 'http://localhost:9200/test/_forcemerge?max_num_segments=5'
max_num_segments=1  强制合并成一个段文件

更新索引分析器

It is also possible to define new analyzers for the index. 
But it is required to close the index first and open it after the changes are made.

close 
update analyzers
open 

关闭索引 
更新分析器 
打开索引


curl -XPOST 'localhost:9200/myindex/_close'

curl -XPUT 'localhost:9200/myindex/_settings' -d '{
  "analysis" : {
    "analyzer":{
      "content":{
        "type":"custom",
        "tokenizer":"whitespace"
      }
    }
  }
}'

curl -XPOST 'localhost:9200/myindex/_open'

获取索引设置信息

GET /twitter/_settings

GET /twitter,kimchy/_settings

GET /_all/_settings

GET /log_2013_*/_settings

wildcard matching  通配符匹配
curl -XGET 'http://localhost:9200/2013-*/_settings/index.number_*'


分析分词

curl -XGET 'localhost:9200/_analyze' -d '
{
  "analyzer" : "standard",
  "text" : "this is a test"
}'

curl -XGET 'localhost:9200/_analyze' -d '
{
  "tokenizer" : "keyword",
  "filter" : ["lowercase"],
  "text" : "this is a TEST"
}'

使用 keyword 分析器 ,转成小写输出

curl -XGET 'localhost:9200/_analyze' -d '
{
  "tokenizer" : "keyword",
  "filter" : ["lowercase"],
  "char_filter" : ["html_strip"],
  "text" : "this is a TEST"
}'

去掉html标签 转成小写

curl -XGET 'localhost:9200/_analyze' -d '
{
  "tokenizer" : "whitespace",
  "filter" : ["lowercase", {"type": "stop", "stopwords": ["a", "is", "this"]}],
  "text" : "this is a test"
}'

自定义停词  只返回 test 


curl -XGET 'localhost:9200/test/_analyze' -d '
{
  "text" : "this is a test"
}'

使用指定索引的分析器

curl -XGET 'localhost:9200/test/_analyze' -d '
{
  "analyzer" : "whitespace",
  "text" : "this is a test"
}'

自定义分析器

curl -XGET 'localhost:9200/test/_analyze' -d '
{
  "field" : "obj1.field1",
  "text" : "this is a test"
}'

使用指定字段的分析器
Will cause the analysis to happen based on the analyzer 
configured in the mapping for obj1.field1 (and if not, the default index analyzer).

http://localhost:9200/_analyze?tokenizer=keyword&filter=lowercase&text=this+is+a+test

Explain Analyze
解释分析

If you want to get more advanced details, 
set explain to true (defaults to false). 
It will output all token attributes for each token. 
You can filter token attributes you want to output by setting attributes option.

explain设置为true(默认设置为false),获取详细的分分词析信息。
它将输出每个词元属性。可以通过设置attributes选项来筛选要输出的属性。


GET _analyze
{
  "tokenizer" : "standard",
  "filter" : ["snowball"],
  "text" : "this is a test",
  "explain" : true,
  "attributes" : ["keyword"] 
}


索引模板 
对新创建的索引应用模板 
Templates are only applied at index creation time. 
Changing a template will have no impact on existing indices.

上一篇     下一篇
通过男女关系形象解读大数据技术

elasticsearch5.0索引别名

elasticsearch5.0索引映射管理

elasticsearch5.0索引监控

elasticsearch5.0索引状态管理

线上故障处理