java

elasticsearch7.10.2常用rest-api

文档地址: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

1、http://192.168.2.111:9200/_cat/nodes?v ------------------查看所有节点

2、http://192.168.2.111:9200/_cat/indices?v ---------------查看所有索引

3、http://192.168.2.111:9200/_cat/health?v -------------查看集群相关信息

4、http://192.168.2.111:9200/_cluster/health?pretty----------查看集群健康指标

5、http://192.168.2.177:9200/test_index1/_search?pretty&track_total_hits=true-----查询文档

6、http://192.168.2.177:9200/test_index1/_doc/1?pretty ----根据id查询

7、http://192.168.2.177:9200/test_index1/_mapping?pretty ----查看mapping

8、http://192.168.2.177:9200/test_index1/_settings?pretty---查看setting

9、http://192.168.56.101:9200/_cluster/settings?include_defaults&flat_settings --查看集群默认配置
10、GET _cat/segments/demo-index?v&s=prirep,shard ---查看段
11、POST demo-index/_forcemerge?max_num_segments=1----合并段 这个过程可能执行的时间比较久(合并后每个分片一个段)

1.Index操作api

1.1 create_index

PUT /my-index-000001
{
  "settings": {
    "index": {
      "number_of_shards": 3,  
      "number_of_replicas": 2 
    }
  }
}

1.2 delete_index

DELETE /my-index-000001

1.3 get_index

GET /my-index-000001

1.4忽略html标签

PUT /my-index-000002
{
  "settings": {
    "index.number_of_shards": 1,
    "number_of_replicas": 2,
    "analysis": {
      "analyzer": {
        "html_text_analyzer": {
          "tokenizer": "ik_max_word",
          "char_filter": [
            "html_strip"
          ]
        }
      },
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "search_analyzer": "ik_smart",
        "analyzer": "html_text_analyzer",
        "type": "text"
      }
    }
  }
}

1.5 测试分词

GET http://192.168.6.128:9200/_analyze
{
    "tokenizer": "ik_smart",
    "text": "大数据相关报道",
     "char_filter": [
    "html_strip"
  ],
}

1.6 red修复

http://192.168.6.128:9200/_all/_settings

{
    "index" : {
       "number_of_replicas" : 0
    }
}

关于作者

程序员,软件工程师,java, golang, rust, c, python,vue, Springboot, mybatis, mysql,elasticsearch, docker, maven, gcc, linux, ubuntu, centos, axum,llm, paddlepaddle, onlyoffice,minio,银河麒麟,中科方德,rpm