elasticsearch7.x kibana的常用DSL(自己练习的)

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: elasticsearch7.x kibana的常用DSL(自己练习的)
GET bank/_mapping
GET bank/_search
GET bank/_search
{
  "aggs": {
    "age_group": {
      "range": {
        "field": "age",
        "ranges": [
          {
            "from": 20,
            "to": 29
          },
           {
            "from": 30,
            "to": 39
          },
          {
            "from": 40,
            "to": 49
          }
        ]
      }, 
      "aggs": {
        "gender_group": {
          "terms": {
            "field": "gender.keyword"
          },
          "aggs": {
            "balance_avg": {
              "avg": {
                "field": "balance"
              }
            }
          }
        }
      }
    }
  },
  "size": 0
}
GET bank/_search
{
  "aggs": {
    "state_group": {
      "terms": {
        "field": "state.keyword",
        "order": {
          "balance_avg": "asc"
        }
      },
      "aggs": {
        "balance_avg": {
          "avg": {
            "field": "balance"
          }
        }
      }
    }
  },
  "size": 0
}
GET bank/_search
{
  "aggs": {
    "state_group": {
      "terms": {
        "field": "state.keyword"
      },
      "aggs": {
        "balance_avg": {
          "avg": {
            "field": "balance"
          }
        }
      }
    }
  },
  "size": 0
}
GET bank/_search
{
  "aggs": {
    "state_group": {
      "terms": {
        "field": "state.keyword"
      }
    }
  },
  "size": 0
}
GET bank/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
           "balance": {
            "gte": 20000,
            "lte": 30000
      }
          }
        }
      ]
    }
  },
  "sort": [
    {
      "balance": {
        "order": "desc"
      }
    }
  ]
}
GET bank/_search
{
  "query": {
    "range": {
      "balance": {
        "gte": 20000,
        "lte": 30000
      }
    }
  },
  "sort": [
    {
      "balance": {
        "order": "desc"
      }
    }
  ]
}
GET bank/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "age": 40
          }
        }
      ], 
      "must_not": [
        {
          "match": {
            "state": "ID"
          }
        }
      ]
    }
  }
}
GET bank/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "match": {
            "address": "mill"
          }
        },
        {
           "match": {
            "address": "lane"
          }
        }
      ]
    }
  }
}
GET bank/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "address": "mill"
          }
        },
        {
           "match": {
            "address": "lane"
          }
        }
      ]
    }
  }
}
GET bank/_search
{
  "query": {
    "match_phrase": {
      "address": "mill lane"
    }
  }
}
GET bank/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "address": "mile"
          }
        },
         {
          "match": {
            "address": "lane"
          }
        }
      ]
    }
  }
}
GET bank/_search
{
  "query": {
    "match": {
      "address": "mill lane"
    }
  }
}
GET bank/_search
{
  "query": {
    "match": {
      "address": "mill"
    }
  }
}
GET bank/_search?q=account_number:20
GET bank/_search
{
  "query": {
    "match": {
      "account_number": "20"
    }
  }
}
GET bank/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "account_number": 20
          }
        }
      ]
    }
  }
}
GET /bank/_search
{
  "query": {
    "match_all": {}
  },
  "_source": ["account_number","balance"]
}
GET bank/_search
{
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "balance": {
        "order": "desc"
      }
    }
  ],
  "size": 10
}
POST bank/_update/1
{
  "script":"ctx._source.age+=5"
}
GET bank/_doc/1
POST my_index/_doc
{
  "productName":"雪花啤酒100L"
}
GET my_index/_search
{
  "query": {
    "match": {
      "productName": "xh"
    }
  }
}
PUT /my_index/_mapping
{
  "properties":{
    "productName":{
      "type":"text",
      "analyzer":"ik_pinyin_analyzer",
      "search_analyzer":"ik_pingying_smark"
    }
  }
}
PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ik_pinyin_analyzer": {
          "type": "custom",
          "tokenizer": "ik_smart",
          "filter": [
            "pinyin_max_word_filter"
          ]
        },
        "ik_pingying_smark": {
          "type": "custom",
          "tokenizer": "ik_smart",
          "filter": [
            "pinyin_smark_word_filter"
          ]
        }
      },
      "filter": {
        "pinyin_max_word_filter": {
          "type": "pinyin",
          "keep_full_pinyin": "true", 
          "keep_separate_first_letter": "true",
          "keep_joined_full_pinyin": true 
        },
        "pinyin_smark_word_filter": {
          "type": "pinyin",
          "keep_separate_first_letter": "false", 
          "keep_first_letter": "false"     
        }
      }
    }
  }
}
POST /_analyze
{
  "analyzer": "pinyin",
  "text":"我是中国人"
}
POST /_analyze
{
  "analyzer": "simple",
  "text": "决战到天亮"
}
POST /_analyze
{
  "analyzer": "ik_smart",
  "text": "我是中国人"
}
POST /_analyze
{
  "analyzer": "ik_max_word",
  "text": "太白"
}
POST bank/_search
{
  "aggs": {
    "group_by_age": {
      "range": {
        "field": "age",
        "ranges": [
          {
            "from": 20,
            "to": 30
          },
          {
            "from": 30,
            "to": 40
          },
          {
            "from": 40,
            "to": 50
          }
        ]
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "terms": {
        "field": "age"
      },
      "aggs": {
        "count": {
          "top_hits": {
            "size": 3
          }
        }
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "terms": {
        "field": "age"
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "value_count": {
        "field": "age"
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "extended_stats": {
        "field": "age"
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "cardinality": {
        "field": "age"
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs": {
    "taibai": {
      "avg": {
        "script": {
          "source": "doc.age.value"
        }
      }
    }
  },
  "size": 0
}
POST bank/_search
{
  "aggs":{
    "taibai":{
      "avg":{
        "field": "age"
      }
    }
  },
  "size":0
}
GET taibai/_search
{
  "query": {
     "bool": {
       "must": 
         {
           "term": {
             "sex":  "男"
           }
         },
         "must_not": 
         {
           "term": {
             "age":  "29"
           }
         },
         "should":[
           {
             "term":{
             "sex": "男"
             }
           },
            {"term":{
              "id": "1003"
            }
           }
         ]
     }
  }
}
GET taibai/_search
{
  "query": {
    "match": {
      "name": "三"
    }
  }
}
GET taibai/_search
{
  "query": {
    "range": {
      "age": {
        "gte": 20,
        "lte": 30
      }
    }
  }
}
GET taibai/_search
{
  "query": {
    "exists": {
      "field": "age"
    }
  }
}
GET taibai/_search
{
  "query": {
    "term": {
      "name.keyword": "张三"
    }
  }
}
POST /_analyze
{
  "analyzer":"standard",
  "text":"决战到天亮"
}
POST /_analyze
{
  "analyzer":"ik_max_word",
  "text":"决战到天亮"
}
POST /_analyze
{
  "analyzer": "standard",
  "text": "张三"
}
GET taibai/_mapping
GET taibai/_search
{
  "query": {
    "term": {
      "name": "张三"
    }
  }
}
GET taibai/_search
GET /bank/_search
{
  "size": 2,
  "from": 0,
  "sort": [
    {
      "_id": {
        "order": "asc"
      }
    }
  ],
  "search_after":[
    1
  ]
}
//浅分页
GET bank/_search
{
  "size": 20,
  "from": 0,
  "sort": [
    {
      "_id": {
        "order": "desc"
      }
    }
  ]
}
GET /bank/_search?scroll=5m
{
  "size": 20,
  "from": 0,
  "sort": [
    {
      "_id": {
        "order": "desc"
      }
    }
  ]
}
GET _search/scroll
{
  "scroll_id":
  "FGluY2x1ZGVfY29udGV4dF91dWlkDXF1ZXJ5QW5kRmV0Y2gBFkM2RkJhMEFGU3g2OWZLQ0trNEpzcVEAAAAAAAAIyBZ4UEV6VFpWTlFoZXNhMkRQNHdZZVh3",
   "scroll":"5m"
}
DELETE _search/scroll/FGluY2x1ZGVfY29udGV4dF91dWlkDXF1ZXJ5QW5kRmV0Y2gBFkM2RkJhMEFGU3g2OWZLQ0trNEpzcVEAAAAAAAAIyBZ4UEV6VFpWTlFoZXNhMkRQNHdZZVh3
DELETE _search/scroll/_all
GET bank/_search
{
  "query": {
    "match_all": {}
  },
   "sort": [
    {
      "_id": {
        "order": "asc"
      }
    }
  ],
  "size": 4,
  "from": 0
}
POST _bulk 
{ "create" :{ "_index" : "taibai", "_id" : "101" } }
{"id":101,"name":"name1","age": 20,"sex": "男"} 
{ "create" : { "_index" : "taibai", "_id" : "401" }}
{"id":401,"name":"name1","age": 20,"sex": "男"}
POST _bulk
{ "update" :{ "_index" : "taibai", "_id" : "101" } }
{"doc": {"id":101,"name":"name101","age": 201,"sex": "男101"}}
{ "update" : { "_index" : "taibai", "_id" : "401" }}
{"doc": {"id":401,"name":"name401","age": 20401,"sex": "男401"}}
POST _bulk 
{ "delete":{ "_index" : "taibai", "_id":"101" }}
{ "delete": { "_index" : "taibai", "_id":"401" }} 
GET taibai/_search
GET /bank/_mget
{
  "ids":[
    "1","40"
    ]
}
GET bank/_source/40?_source=age,email
GET bank/_doc/40?_source=id,name
GET bank/_search?q=age:23
GET bank/_search
{
  "query": {
    "match_all": {}
  },
  "size": 1000,
  "from": 0
}
GET taibai/_search
POST taibai/_doc
{
  "id":1001,
  "name" : "张三",
  "age" : 22,
  "sex" : "男"
}
GET kuangshen/user/_search
{
  "query":{
    "match": {
      "name": "狂神"
    }
  },
  "_source":["name","desc"] 
}
POST taibai/_doc/1001
{
  "id":1002,
  "name":"太白"
}
GET taibai/_search
PUT /taibai
{
  "settings": {
    "number_of_replicas": 0,
    "number_of_shards": 1
  }
}
DELETE taibai
POST taibai/_doc
{
  "id":1001,
  "name":"taibai"
}
PUT taibai/_doc/1002
{
  "id":1002,
  "name":"taibai",
   "age":21,
   "sex":"哈哈"
}
POST /taibai/_update/1002
{
  "doc": {
    "age":21
  }
}
GET /taibai/_doc/1002
DELETE taibai/_doc/9gU0l3sBa2-WIiyKQyQG

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
2月前
|
数据可视化 Java Windows
Elasticsearch入门-环境安装ES和Kibana以及ES-Head可视化插件和浏览器插件es-client
本文介绍了如何在Windows环境下安装Elasticsearch(ES)、Elasticsearch Head可视化插件和Kibana,以及如何配置ES的跨域问题,确保Kibana能够连接到ES集群,并提供了安装过程中可能遇到的问题及其解决方案。
Elasticsearch入门-环境安装ES和Kibana以及ES-Head可视化插件和浏览器插件es-client
|
19天前
|
自然语言处理 搜索推荐 关系型数据库
elasticsearch学习六:学习 全文搜索引擎 elasticsearch的语法,使用kibana进行模拟测试(持续更新学习)
这篇文章是关于Elasticsearch全文搜索引擎的学习指南,涵盖了基本概念、命令风格、索引操作、分词器使用,以及数据的增加、修改、删除和查询等操作。
14 0
elasticsearch学习六:学习 全文搜索引擎 elasticsearch的语法,使用kibana进行模拟测试(持续更新学习)
|
19天前
|
存储 JSON Java
elasticsearch学习一:了解 ES,版本之间的对应。安装elasticsearch,kibana,head插件、elasticsearch-ik分词器。
这篇文章是关于Elasticsearch的学习指南,包括了解Elasticsearch、版本对应、安装运行Elasticsearch和Kibana、安装head插件和elasticsearch-ik分词器的步骤。
76 0
elasticsearch学习一:了解 ES,版本之间的对应。安装elasticsearch,kibana,head插件、elasticsearch-ik分词器。
|
21天前
|
运维 监控 数据可视化
大数据-171 Elasticsearch ES-Head 与 Kibana 配置 使用 测试
大数据-171 Elasticsearch ES-Head 与 Kibana 配置 使用 测试
38 1
|
2月前
|
NoSQL 关系型数据库 Redis
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
mall在linux环境下的部署(基于Docker容器),docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongodb、minio详细教程,拉取镜像、运行容器
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
|
2月前
|
JSON 自然语言处理 算法
ElasticSearch基础2——DSL查询文档,黑马旅游项目查询功能
DSL查询文档、RestClient查询文档、全文检索查询、精准查询、复合查询、地理坐标查询、分页、排序、高亮、黑马旅游案例
ElasticSearch基础2——DSL查询文档,黑马旅游项目查询功能
|
2月前
|
JSON 自然语言处理 数据库
ElasticSearch基础1——索引和文档。Kibana,RestClient操作索引和文档+黑马旅游ES库导入
概念、ik分词器、倒排索引、索引和文档的增删改查、RestClient对索引和文档的增删改查
ElasticSearch基础1——索引和文档。Kibana,RestClient操作索引和文档+黑马旅游ES库导入
|
3月前
|
数据可视化 Docker 容器
一文教会你如何通过Docker安装elasticsearch和kibana 【详细过程+图解】
这篇文章提供了通过Docker安装Elasticsearch和Kibana的详细过程和图解,包括下载镜像、创建和启动容器、处理可能遇到的启动失败情况(如权限不足和配置文件错误)、测试Elasticsearch和Kibana的连接,以及解决空间不足的问题。文章还特别指出了配置文件中空格的重要性以及环境变量中字母大小写的问题。
一文教会你如何通过Docker安装elasticsearch和kibana 【详细过程+图解】
|
3月前
|
消息中间件 监控 Kafka
Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
【8月更文挑战第13天】Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
158 3
|
3月前
|
自然语言处理 Docker 容器
ElasticSearch 实现分词全文检索 - ES、Kibana、IK分词器安装
ElasticSearch 实现分词全文检索 - ES、Kibana、IK分词器安装
43 0

热门文章

最新文章