zoukankan      html  css  js  c++  java
  • ElasticSearch7.6.2中语法使用(更新中)

    1、统计loginName去重后的数量

    GET /login_user_info/_search
    {
    "size":0,
    "query":{"bool":{"filter":[{"terms":{"systemCd.keyword":["AAAAA"]}},
    {"query_string":{"default_field":"userTypeCd.keyword","query":"2"}}],"adjust_pure_negative":true,"boost":1.0}},
    "track_total_hits":2147483647,
    "aggregations":{"userNum":{"cardinality":{"field":"loginName.keyword"}}}
    }

    2、将customer的值替换为loginName的值

    POST login_user_info/_update_by_query
    {
        "query":{"bool":{"filter":[{"query_string":{"default_field":"systemCd.keyword","query":"AAAAA"}},
        {"query_string":{"default_field":"userTypeCd.keyword","query":"2"}}],"adjust_pure_negative":true,"boost":1.0}},
        "script":{"inline": "ctx._source['customer'] = ctx._source['loginName']"},
        "track_total_hits":2147483647
    }

    3、时间范围查询

    GET /login_user_info/_search
    {
    "query":{"bool":{"filter":[{"range":{"createTime":{"from":"2020-09-01T00:00:00.000Z","to":"2020-10-31T23:59:59.000Z",
            "include_lower":true,"include_upper":true,"boost":1.0}}}],
            "adjust_pure_negative":true,"boost":1.0}},
    "track_total_hits":2147483647
    }

    4、异步多线程删除数据

    # wait_for_completion=false : 开启异步
    # scroll_size=2000 : 删除文档数
    # slices=2 : 线程数量
    # conflicts=proceed : 冲突继续执行
    
    POST login_user_info/_delete_by_query?wait_for_completion=false&conflicts=proceed&scroll_size=10000&slices=10
    {"query":{"bool":{"filter":[{"range":{"createTime":{"from":"2020-09-01T00:00:00.000Z",
    "to":"2020-10-31T23:59:59.000Z","include_lower":true,"include_upper":true,"boost":1.0}}}],"adjust_pure_negative":true,"boost":1.0}},"track_total_hits":2147483647}

     5、计算user索引下每个systemCd下的文档数量, 请求语法

    GET user/_search
    {
        "size": 0,  
        "from": 20, 
        "aggs": {
            "group_by_tags": {    
                "terms": {
                    "field": "systemCd.keyword"
                }
            }
        },"track_total_hits":2147483647
    }

      

  • 相关阅读:
    【Go】windows下搭建go语言编译环境
    【java回调】同步/异步回调机制的原理和使用方法
    【tomcat】tomcat远程调试
    【tomcat】获取访问者真实IP
    【深度学习学习记录】之一:开篇闲扯一些话
    【java】线程安全的整型类AtomicInteger
    【OpenStack】源码级深入了解删除虚拟机操作
    【Maven】maven的常用命令以及搭建maven私人仓库
    素 数 (第三届省赛)
    房间安排(第三届省赛)
  • 原文地址:https://www.cnblogs.com/wueryuan/p/14549628.html
Copyright © 2011-2022 走看看