Elasticsearch常用API

查看
查看集群健康状态
GET /_cluster/health
查看节点
GET /_cluster/state/nodes
查看健康状态
GET _cat/health?v
查看所有索引
GET _cat/indices?v
查看磁盘状态
GET _cat/allocation?v
查询
存入文档
POST /index_test/type_test/id_test
{
    "name":"小明",
    "age":18,
    "address":"北京市东大街"
}
普通查询
GET /index_test/type_test/id_test
条件查询
GET /index_test/type_test1/_search?q=4444
布隆过滤器
POST /_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "address": "北"
          }
        },
        {
          "term": {
            "address": "京"
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "from": 0,
  "size": 10,
  "sort": []
}
mapping
查询
GET /index*/type_test/_mapping
添加索引及mapping
PUT index_test
{
  "settings": {
    },
  "mappings": {
     "type": {
        "properties": {
           "name": {
              "type": "keyword"
           },
           "address": {
              "type": "text"
           }
        }
     }
  }
}
添加mapping
PUT index_test/_mapping/type
{
  "type": {
        "properties": {
           "name": {
              "type": "keyword"
           },
           "address": {
              "type": "text"
           }
        }
     }
}
pipeline
测试模拟pipeline
POST _ingest/pipeline/_simulate
{
  "docs": [
    {
      "_index": "index"
      "_source": {
        "foo": "rab",
        "message": "[2020-12-23 19:50:04.699][ERROR][requestId:] [fixed-127.0.0.1_8848] [sub-server] get s"
      }
    }
  ],
  "pipeline":{
      "processors" : [
      {
        "grok": {
          "field": "message",
          "patterns": ["\\[%{EVENTDATE:time}%{GREEDYDATA}requestId:%{REQUESTID:request_id}\\]%{ANYS}"],
          "pattern_definitions": {
            "EVENTDATE":"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}",
            "REQUESTID":".{0,10}",
            "ANYS":"[\\d\\D]*"
          }
        }
      }
    ]
  }
}
添加
PUT _ingest/pipeline/file-beat-pipeline
{
  "description" : "filebeat转换",
  "processors" : [
    {
      "grok": {
          "field": "message",
          "patterns": ["\\[%{EVENTDATE:time}%{GREEDYDATA}requestId:%{REQUESTID:request_id}\\]%{ANYS}"],
          "pattern_definitions": {
            "EVENTDATE":"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}",
            "REQUESTID":".{0,10}",
            "ANYS":"[\\d\\D]*"
          }
        },
      "remove": {
        "field": "input_type"
      }
    }
  ]
}
查看
GET _ingest/pinpeline/file-beat-pipeline
删除
DELETE _ingest/pipeline/file-beat-pipeline
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容