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 -- ...
随机推荐
- Java的static类
首先Java的static类只能是静态内部类.如果在外部类声明为static,程序会编译通不过. 其次,主要了解下static内部类与普通内部类的区别是什么,以及static内部类的作用是什么,详见下 ...
- pandas爬虫
import pandas as pd import re pat=re.compile("shenfenzheng = (.*?);") ###果树财富 class RongSh ...
- python装饰器的4种类型:函数装饰函数、函数装饰类、类装饰函数、类装饰类
一:函数装饰函数 def wrapFun(func): def inner(a, b): print('function name:', func.__name__) r = func(a, b) r ...
- OpenStack实践系列⑧可视化服务Horizon之Dashboard演示
OpenStack实践系列⑧可视化服务Horizon之Dashboard演示 七.可视化服务Horizon之Dashboard演示 仪表板依赖于功能核心服务,包括身份,图像服务,计算和网络两种(neu ...
- var_export 掉咋天
var_export 文件缓存经常使用 输出或返回一个变量的字符串表示 /** * 写入缓存 * * @param string $id * @param mixed $data * @ ...
- 36)django-jsonp跨域
一:什么是JSONP JSONP(JSON with Padding)是JSON的一种"使用模式",可用于解决主流浏览器的跨域数据访问的问题.由于同源策略,一般来说位于 serve ...
- 大数据python词频统计之hdfs分发-cacheFile
-cacheFile 分发,文件事先上传至Hdfs上,分发的是一个文件 1.找一篇文章The_Man_of_Property.txt: He was proud of him! He could no ...
- JVM·垃圾收集器与内存分配策略之对象是否可被回收!
1.判断对象已经死去/不再被引用. 1.1.引用计数算法:给对象添加引用计数器,有个地方引用就+1,引用失效就-1.任何时刻,引用为0,即判断对象死亡. 1.1.1.优点:实现 ...
- (六)STL仿函数functor
1.仿函数为算法服务,特点是重载操作符() 2.一共分为3大类,包括算术类,逻辑运算类,相对关系(比较大小):都继承了binary_function 3.仿函数的一些调用示例,其中右边的仿函数没有继承 ...
- 洛谷 P3627 [APIO2009]抢掠计划
这题一看就是缩点,但是缩完点怎么办呢?首先我们把所有的包含酒吧的缩点找出来,打上标记,然后建立一张新图, 每个缩点上的点权就是他所包含的所有点的点权和.但是建图的时候要注意,每一对缩点之间可能有多条边 ...