elasticsearch 聚合函数 max double精度损失bug
测试样例数据
{
"size" : 0,
"query" : {
"bool" : {
"must" : {
"bool" : {
"must" : {
"bool" : {
"must" : {
"match" : {
"cankwxzwtm" : {
"query" : "丹参",
"type" : "phrase"
}
}
}
}
}
}
}
}
},
"aggregations" : {
"group_docid" : {
"terms" : {
"field" : "docid.raw",
"size" : 1000
},
"aggregations" : {
"maxid" : {
"max" : {
"field" : "longId"
}
}
}
}
}
}
测试结果数据
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"failed": 0
},
"hits": {
"total": 24,
"max_score": 0,
"hits": []
},
"aggregations": {
"group_docid": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "995922987708317699",
"doc_count": 4,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317703",
"doc_count": 2,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317708",
"doc_count": 2,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987712512006",
"doc_count": 2,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512012",
"doc_count": 2,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987704123392",
"doc_count": 1,
"maxid": {
"value": 995922987704123390
}
},
{
"key": "995922987708317700",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317701",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317704",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317705",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317706",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317709",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987712512002",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512007",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512009",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512010",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512011",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
}
]
}
}
}
总结:maxid.value的值精度已经损失,没去官网深究原因,用terms替换max方法,得出所有id值,手动筛选值。
elasticsearch 聚合函数 max double精度损失bug的更多相关文章
- js double 精度损失 bugs
js double 精度损失 bugs const arr = [ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 ]; // [ ...
- js 小数转整数,避免精度损失 bug
js 小数转整数,避免精度损失 bug const arr = [ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 ]; // ( ...
- java 常用类库:BigInteger大整数;BigDecimal大小数(解决double精度损失);
大整数BigInteger package com.zmd.common_class_libraries; import java.math.BigInteger; /** * @ClassName ...
- Java中关于 BigDecimal 的一个导致double精度损失的"bug"
背景 在博客 恶心的0.5四舍五入问题 一文中看到一个关于 0.5 不能正确的四舍五入的问题.主要说的是 double 转换到 BigDecimal 后,进行四舍五入得不到正确的结果: public ...
- GROUP BY 聚合函数(max min sum avg count) 和HAVING的 使用
重新复习一下这个都源自于我经常需要查的一个需求 “要找到表里面 出现了两次或者三次的某个字段” 现在假设有一张表字段是 +----+---------------------+------------ ...
- elasticsearch聚合函数
计算每个tag下的商品数量 GET /ecommerce/product/_search { "aggs": { //聚合 "group_by_tags": ...
- ElasticSearch 聚合函数
一.简单聚合 桶 :简单来说就是满足特定条件的文档的集合. 指标:大多数 指标 是简单的数学运算(例如最小值.平均值.最大值,还有汇总),这些是通过文档的值来计算. 桶能让我们划分文档到有意义的集合, ...
- oracle中的常用函数、字符串函数、数值类型函数、日期函数,聚合函数。
一.字符串的常用函数. --一.oracle 字符串常用函数 --1. concat 连接字符串的函数,只能连接[两个]字符串. 字符写在括号中,并用逗号隔开! --2."||"符 ...
- 第17课-数据库开发及ado.net 聚合函数,模糊查询like,通配符.空值处理.order by排序.分组group by-having.类型转换-cast,Convert.union all; Select 列 into 新表;字符串函数;日期函数
第17课-数据库开发及ado.net 聚合函数,模糊查询like,通配符.空值处理.order by排序.分组group by-having.类型转换-cast,Convert.union all; ...
随机推荐
- Collection集合复习方法回顾
Collection集合方法: add() //添加元素 remove() //移除元素 size() //返回集合长度 ...
- 2--Python入门--Python数据集合类型--列表
在基础数据类型的基础上,Python有6中数据集合的类型: 列表list,最常用的数据类型,以[]为标识 元组tuple,和list很相似,但是不能二次赋值,用()标识 集合set,和list类似,但 ...
- 当超强台风“山竹”即将冲进南海,Power BI 你怎么看?
这个周末“山竹 ”强势来袭!很多人的目光都在关注暴力水果“山竹”,这个号称70年最强最大风力超17级 台风“山竹”今天就已经在小悦家窗台肆虐咆哮了一天了!不知其他的小伙伴们是不是好好的一个周末就只能被 ...
- maven 细节 —— scope、坐标
对于 idea 开发环境,测试代码便是在 src/test/java(该java目录会在创建时标注为测试文件夹) 目录下的 .java 代码为测试代码: 1. scope scope的分类 compi ...
- Python 爬虫工具 —— fake_useragent
服务器为避免爬虫工具无休止的请求,以减轻负载,会对 user agent 进行校验,即判断某一 user-agent 是否不断地进行请求.可采用如下方式进行绕过服务器的校验. UserAgent_Li ...
- TCP三次握手及释放连接详解(转)
一.TCP头部简介 ACK :即确认字符,在数据通信中,接收站发给发送站的一种传输类控制字符.表示发来的数据已确认接收无误.TCP报文格式中的控制位由6个标志比特构成,其中一个就是ACK,ACK为1表 ...
- upstream timed out (110: Connection timed out) while reading response header from upstream
Nginx报错日志有如下内容: upstream timed out (110: Connection timed out) while reading response header from up ...
- fast ai环境配置
https://www.jianshu.com/p/2fe22a6b0ecb https://www.jianshu.com/p/b1be2af2f2ef https://blog.csdn.net/ ...
- PTA——天平找小球
PTA 7-22 用天平找小球 #include<stdio.h> int main() { int a,b,c; scanf("%d%d%d",&a,& ...
- linux下简单制作iso,img镜像文件
1. 如果你是直接从cd压制iso文件的,执行sudo umount /dev/cdromdd if=/dev/cdrom of=file.iso bs=1024 2. 如果你要把某个文件或者目录压到 ...