es创建索引和yellow排查解决

索引创建

PUT /index_name
{
  "settings": {
    "index": {
      "refresh_interval": "30s",
      "number_of_shards": "3",
      "max_result_window": "100000000", 
      "analysis": {
        "filter": {
          "escapeLen": {
            "type": "length",
            "max": "30",
            "min": "2"
          }
        },
        "analyzer": {
          "escapeHtml": {
            "filter": [
              "escapeLen"
            ],
            "char_filter": [
              "html_strip"
            ],
            "tokenizer": "ik_smart"
          }
        }
      },
      "number_of_replicas": "2" 
    }
  }
}

POST /index_name/_mapping
{

    "properties": {
      
      "content": {
        "type": "text",
        "term_vector": "with_positions_offsets",
        "analyzer": "escapeHtml",
        "search_analyzer": "ik_smart"
      },
      "title": {
        "type": "text",
        "term_vector": "with_positions_offsets",
        "analyzer": "escapeHtml",
        "search_analyzer": "ik_smart",
        "fielddata": true
      }
    }
  
}

索引删除

DELETE /my_index_name

判断字段是否存在

POST myindex/_search
{

	"query": {
		"bool": {
			"must": [
			  {
			    "exists": {"field": "match_title"}
			  }
			], 
			
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	},
	"track_total_hits": 2147483647
}

增加数据

PUT myindex/_doc/{id}
{
  "title":"1111",
  "content":"22222"
}

yellow 排查解决 常见请求

GET /_cat/shards?h=index,shard,prirep,state,unassigned.reason  查询原因

GET /_cluster/health  查询健康

GET /_cluster/allocation/explain?pretty


GET /index_name/_settings 查看设置

PUT /index_name/_settings  重置分片
{"number_of_replicas": 0}

PUT /index_name/_settings 重新分配
{"number_of_replicas": 2}

reached the limit of incoming shard recoveries [2], cluster setting [cluster.routing.allocation.node_concurrent_incoming_recoveries=2] (can also be set via [cluster.routing.allocation.node_concurrent_recoveries])
这种情况通常出现在集群重启,或者某一个节点重启后。且由于设置的分片并发恢复的值较低导致。为了尽快恢复集群健康状态。
解决方法:可以通过调用下面的API来提升分片恢复的速度和并发度:

PUT /_cluster/settings
{
    "transient" : {
        "cluster.routing.allocation.node_concurrent_recoveries": "20",
        "indices.recovery.max_bytes_per_sec": "100mb"
    }
}
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Elasticsearch创建索引和副本,您需要使用Elasticsearch提供的API或Elasticsearch的客户端库来执行以下步骤: 1. 创建索引:要创建索引,您需要使用Elasticsearch的“Index” API。例如,以下命令将创建一个名为“my_index”的索引: ``` PUT /my_index { "settings": { "number_of_shards": 1, "number_of_replicas": 1 } } ``` 在这个例子中,我们使用PUT请求指定索引名称,并提供一个包含索引设置的JSON对象。在这种情况下,我们指定了一个主分片和一个副本分片。 2. 创建副本:要创建副本,您需要使用Elasticsearch的“Update Settings” API。例如,以下命令将为“my_index”索引创建一个额外的副本: ``` PUT /my_index/_settings { "index": { "number_of_replicas": 2 } } ``` 在这个例子中,我们使用PUT请求指定索引名称和新的副本设置。注意,我们只指定了副本数量,并且没有修改主分片的数量。 3. 检查索引和副本数量:要检查索引和副本数量,您需要使用Elasticsearch的“Get Settings” API。例如,以下命令将检索“my_index”索引的当前设置: ``` GET /my_index/_settings ``` 在这个例子中,我们使用GET请求指定索引名称,并检索当前的索引设置。您可以查看响应结果,以确定主分片和副本分片的数量是否已更新。 请注意,要在Elasticsearch创建索引和副本,您需要具有管理权限。如果您没有这些权限,则需要与Elasticsearch管理员或拥有这些权限的其他人员联系。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值