【ElasticSearch的点点滴滴】第二篇:PUT相关操作

  1. 创建索引
PUT /gyy_index_test
  1. 设置索引
PUT gyy_index_test
{
  "settings":{"index.analysis.analyzer.key_analyzer.type":"custom",
  "index.analysis.analyzer.key_analyzer.tokenizer": "keyword",
  "index.analysis.analyzer.key_analyzer.filter":["lowercase"],
  "index.analysis.analyzer.text_analyzer.tokenizer":"standard",
  "index.analysis.analyzer.text_analyzer.filter":["lowercase"],
  "index.analysis.analyzer.text_stop_analyzer.type":"custom",
  "index.analysis.analyzer.text_stop_analyzer.tokenizer":"standard",
  "index.analysis.analyzer.text_stop_analyzer.filter":["lowercase", "english_stop"],
  "index.analysis.filter.english_stop.type":"stop",
  "index.analysis.filter.english_stop.stopwords":"_english_"
  }
}
  1. 修改集群配置
PUT _cluster/settings
{ 
	"persistent" : { 
	"discovery.zen.minimum_master_nodes": 2 
	} 
}

CURL命令
curl -XPUT localhost:9200/_cluster/settings -d '{ 
	"persistent" : { 
	"discovery.zen.minimum_master_nodes": 2 
	} 
}'
transient 表示临时的,persistent表示永久的

增加集群bulk队列大小

PUT _cluster/settings
{
    "transient" : 
        {
          "threadpool.bulk.queue_size":"200"
        }
}
  1. 设置mapping
PUT {index}/{type}/_mapping 
{ 
	"{type}" : { 
		"properties" : { 
			"date" : { 
				"type" : "long" 
			}, 
			"name" : { 
				"type" : "text", 
				"index" : "not_analyzed" 
			}, 
			"status" : { 
				"type" : "integer" 
			}, 
			"type" : { 
				"type" : "integer" 
			} 
		} 
	} 
}

curl命令
curl -XPUT http://localhost:9200/{index}/{type}/_mapping -d '{ 
	"{type}" : { 
		"properties" : { 
			"date" : { 
				"type" : "long" 
			}, 
			"name" : { 
				"type" : "text", 
				"index" : "not_analyzed" 
			}, 
			"status" : { 
				"type" : "integer" 
			}, 
			"type" : { 
				"type" : "integer" 
			} 
		} 
	} 
}'

“dynamic”:“false”, //关闭自动添加字段,关闭后索引数据中如果有多余字段不会修改mapping,默认true
“_id”:{“index”:“not_analyzed”,“store”:“no”},//设置文档标识符可以被索引,默认不能被索引。可以设置为"_id":{“path”:“book_id”},这样将使用字段book_id作为标识符
“_all”:{“enabled”:“false”},//禁用_all字段,_all字段包含了索引中所有其他字段的所有数据,便于搜索。默认启用  “_source”:{“enabled”:“false”},//禁用_source字段,_source字段在生成索引过程中存储发送到elasticsearch的原始json文档。elasticsearch部分功能依赖此字段(如局部更新功能),因此建议开启。默认启用
“_index”:{“enabled”:“true”},//启用_index字段,index字段返回文档所在的索引名称。默认关闭。
“_timestamp”:{“enabled”:“true”,“index”:“not_analyzed”,“store”:“true”,“format”:“YYYY-mm-dd”},//启用时间戳并设置。时间戳记录文档索引时间,使用局部文档更新功能时,时间戳也会被更新。默认未经分析编入索引但不保存。
“_ttl”:{“enabled”:“true”,“default”:“30d”},//定义文档的生命周期,周期结束后文档会自动删除。
“_routing”:{“required”:“true”,“path”:“customerID”}

PUT /normal_test_event_201711_001/_mapping/t_clue_mobile
{
  "t_clue_mobile":{
          "properties": {
                "90034_m_ueip.keyword": {
                            "type": "long",
                            "index": "not_analyzed"
                    }
                }
  }
}
  1. 修改索引配置
    修改索引刷新时间
PUT /gyy_index_test/_settings
{
  "index.refresh_interval" : "10s"
}

修改界面显示数据量

PUT /ipearl_test_event_201711_001/_settings
{
  "index.max_result_window" : "10000000"
}

修改副本数

PUT /js_event_index_201712_002/_settings
{
  "index.number_of_replicas" : "0"
}
  1. 配置熔断器
PUT /_cluster/settings
{
 "persistent" : { 
	"indices.breaker.total.limit" : 30%,
	"indices.breaker.fielddata.limit" : 3%,
	"indices.breaker.request.limit" : 6%,
	"indices.queries.cache.size" : 5%,
	"indices.queries.cache.count" : 2000 
	}
}
curl命令
curl -XPUT 'http://172.168.1.201:9200/_cluster/settings' -d '{
 "persistent" : { 
	"indices.breaker.total.limit" : 30%,
	"indices.breaker.fielddata.limit" : 3%,
	"indices.breaker.request.limit" : 6%,
	"indices.queries.cache.size" : 5%,
	"indices.queries.cache.count" : 2000 
	}
}'
  1. 插入文档
PUT /ipearl_test_object_001/t_vitualacc/all_dany@patrimonio.ohc2.cu
{
          "ID": "2018011116384000000000000003251193",
          "TIME": "2018-01-11 16:38:40",
          "type": "EMAIL",
          "id": "dany@patrimonio.ohc2.cu",
          "account": "dany@patrimonio.ohc2.cu",
          "data_type": "0"
}
  1. 自定义分词器
PUT ngram_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "my_tokenizer"
        }
      },
      "tokenizer": {
        "my_tokenizer": {
          "type": "ngram",
          "min_gram": 1,
          "max_gram": 3,
         "token_chars": [
            "letter",
            "digit"
          ]
        }
      }
    }
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值