Elasticsearch 备忘
Elasticsearch7.0版本在查询时需要增加 “track_total_hits”:true 来强制进行准确的计数,默认为 “track_total_hits”:10000,
而且返回的hits下结构也和Elasticsearch 6.x 版本的稍有不同,可能还有其他不同的地方,所以将6.x 升级到7.0还是要小心一些
创建index (注意:7.0版本之前mappings中需要增加_doc,7.0版之后已去掉)
PUT http://10.10.x.x:9200/test
{
"settings": {
"index": {
"number_of_shards": "",
"number_of_replicas": ""
}
},
"mappings": {
"_doc": {
"properties": {
"pk": {
"type": "long"
},
"create_time": {
"format": "yyyy-MM-dd HH:mm:ss",
"type": "date"
},
"name": {
"type": "keyword"
}
}
}
}
}
排序
{
"size": ,
"query": {
"bool": {
"must": [
{
"term":
{
"request_uri":"/blog_expand/get_article_expand"
}
}
]
}
},
"sort": [
{ "request_time": { "order": "desc" } }
]
}
根据条件删除
POST http://IP:9200/索引名/_delete_by_query
POST http://10.10.14.111:9200/t_sys_login_log/_delete_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"area_code": "abc"
}
},
{
"range": {
"request_time": {
"gte": "2018-08-21 00:00:01",
"lt": "2018-08-21 23:59:59"
}
}
}
]
}
}
}
创建mapping
PUT http://192.168.0.1:9200/student_zipper
{
"mappings": {
"doc": {
"properties": {
"student_id": {
"type": "keyword"
},
"student_name": {
"type": "keyword"
},
"dw_start_date": {
"type": "date",
"format": "yyyy-MM-dd"
},
"dw_end_date": {
"type": "date",
"format": "yyyy-MM-dd"
}
}
}
}
}
插入数据
POST http://192.168.0.1:9200/student_zipper/doc
{
"student_id": "0417EB01-3F8F-4BC1-9012-436BFF466FBD",
"student_name": "严立诚",
"dw_start_date": "2019-03-10",
"dw_end_date": "9999-01-01"
}
{
"size": 0,
"query": {
"bool": {
"must": [{
"term": {
"area_code": "abcd"
}
}, {
"term": {
"b_use": "1"
}
}, {
"terms": {
"xb_id": [1, 2]
}
}, {
"terms": {
"stage_id": [4, 5, 6]
}
}, {
"terms": {
"district_id": ["300353","300356","300358","300349","300352","300354","310056","300357","300355","300351","300350","300360","300359"]
}
}, {
"range": {
"entrance_year": {
"gte": "2013",
"lte": "2018"
}
}
}]
}
},
"aggs": {
"district_id": {
"terms": {
"field": "district_id",
"size": 1000
},
"aggs": {
"stage_id": {
"histogram": {
"field": "stage_id",
"min_doc_count": 0,
"extended_bounds": {
"min": 4,
"max": 6
},
"interval": 1
},
"aggs": {
"entrance_year": {
"histogram": {
"field": "entrance_year",
"min_doc_count": 0,
"extended_bounds": {
"min": 2013,
"max": 2018
},
"interval": 1
},
"aggs": {
"xb_id": {
"histogram": {
"field": "xb_id",
"min_doc_count": 0,
"extended_bounds": {
"min": 1,
"max": 2
},
"interval": 1
}
}
}
}
}
}
}
}
}
}
Elasticsearch 备忘的更多相关文章
- elasticsearch备忘
1.解决java.lang.RuntimeException: can not run elasticsearch as rootadduser *** //添加用户passwd *** //给用户赋 ...
- GIS部分理论知识备忘随笔
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.高斯克吕格投影带换算 某坐标的经度为112度,其投影的6度带和3度带 ...
- python序列,字典备忘
初识python备忘: 序列:列表,字符串,元组len(d),d[id],del d[id],data in d函数:cmp(x,y),len(seq),list(seq)根据字符串创建列表,max( ...
- Vi命令备忘
备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...
- ExtJs4常用配置方法备忘
viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...
- [备忘] Automatically reset Windows Update components
这两天遇到Windows 10的更新问题,官方有一个小工具,可以用来修复Windows Update的问题,备忘如下 https://support.microsoft.com/en-us/kb/97 ...
- ECMAScript 5(ES5)中bind方法简介备忘
一直以来对和this有关的东西模糊不清,譬如call.apply等等.这次看到一个和bind有关的笔试题,故记此文以备忘. bind和call以及apply一样,都是可以改变上下文的this指向的.不 ...
- MFC通过txt查找文件并进行复制-备忘
MFC基于对话框的Demo txt中每行一个23位的卡号. 文件夹中包含以卡号命名的图像文件.(fpt或者bmp文件) 要求遍历文件夹,找到txt中卡号所对应的图像文件,并复制出来. VC6.0写的. ...
- php 相关模块备忘
在安装php的时候,不管是编译安装: ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -- ...
随机推荐
- 向量的L2范数求导
回归中最为基础的方法, 最小二乘法. \[ \begin{align*} J_{LS}{(\theta)} &= \frac { 1 }{ 2 } { \left\| A\vec { x } ...
- 浅谈Linux下CPU利用率和CPU负载【转】
转自:https://blog.csdn.net/Alisa_xf/article/details/71430406 在Linux/Unix下,CPU利用率(CPU utilization)分为用户态 ...
- mysql死锁-查询锁表进程-分析锁表原因【转】
查询锁表进程: 1.查询是否锁表 show OPEN TABLES where In_use > 0; 2.查询进程 show processlist 查询到相对应的进程===然 ...
- iptables防火墙端口操作
1.将开放的端口写入iptables中,在终端中输入命令: /sbin/iptables -I INPUT -p tcp --dport -j ACCEPT 2.保存上一步的修改内容,输入命令: /e ...
- httplib urllib urllib2 pycurl 比较
最近网上面试看到了有关这方面的问题,由于近两个月这些库或多或少都用过,现在根据自己的经验和网上介绍来总结一下. httplib 实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更 ...
- 【转】RESTful Webservice创建
RESTful Web Services with Java REST stands for REpresentational State Transfer, was first introduc ...
- ranlib 作用
ar 命令用于更新,维护管理静态库. ranlib 命令用于 更新库的符号索引表. 当只执行了ar命令(用于更新)时, ld连接时会仍然报错,查找不到更新的变量或函数,此时需要用ranlib来更新库的 ...
- Uncaught RangeError: Maximum call stack size exceeded
环境: jquery+bootstrap+bootstrapValidator 问题描述:有个form表单,一点击按钮提交,就会报如题错误.正常应该是去校验表单输入. 解决: 从日志分析来看,报错的起 ...
- eclipse:显示堆内存
如下图 :
- workflow的简介
工作流(Workflow) 是对工作流程及其各操作步骤之间业务规则的抽象.概括描述.工作流建模,即将工作流程中的工作如何前后组织在一起的逻辑和规则,在计算机中以恰当的模型表达并对其实施计算. 工作流要 ...