栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ElasticSearch QUERY DSL 记录

ElasticSearch QUERY DSL 记录

查看索引中某个文档

GET 索引名/_doc/id

查询条件

POST  索引名/_search

"from": 0, 分页
  "size": 20,
  "sort": [
    {
      "FIELD": {//排序
        "order": "desc"
      }
    }
   ],  

 "_source": {
    "includes": "{field}",
    "excludes": "{field}"
  }, 
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "字段": {
              "value": "字段值"
            }
          }
        }

        ...
      ]
    }
  }
}

统计符合条件总数

POST  索引名/_count
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "字段": {
              "value": "字段值"
            }
          }
        },

{
        "match": {
          "FIELD": "TEXT"
        }
      },

    {
          "range": {
            "gmtCreate": {
             "from": null,
                          "to": "2021-01-01 00:00:00",
                          "include_lower": true,
                          "include_upper": true,
                          "format": "yyyy-MM-dd HH:mm:ss",
                          "boost": 1.0
            }
          }
        }

        ...
      ]
    }
  }
}

修改数据

POST  索引名/_update_by_query
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "字段": {
              "value": "字段值"
            }
          }
        }

        ...
      ]
    }
  },
  "script": {
    "source": "ctx._source['f1'] = params['fv1'];ctx._source['f2'] = params['fv2']",
    "params": {
      "fv1": 12,
      "fv2":"dddd"
    }
  }
}

删除数据

POST  索引名/_delete_by_query
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "字段": {
              "value": "字段值"
            }
          }
        }

        ...
      ]
    }
  }

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/676763.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号